Npm install failed “cannot run in wd”

使用npm install时,出现了 “cannot run in wd”等字样时,是安装出错了。

需要加上–unsafe-perm参数,完整如下:

npm install --unsafe-perm

或是在package.json中添加:

"config": {
    "unsafe-perm":true
}

官方的解释为:

If npm was invoked with root privileges, then it will change the uid to the user account or uid specified by the user config, which defaults to nobody. Set the unsafe-perm flag to run scripts with root privileges.