Npm 安装因“无法在 wd 中运行”而失败 - Npm install failed with “cannot run in wd”

问题:

I am trying to get my node environment set up on a new Ubuntu 12.04 instance, with Node 0.8.14 already installed, but I ran into problems when I try to run npm install .我正在尝试在新的 Ubuntu 12.04 实例上设置我的节点环境,并且已经安装了 Node 0.8.14,但是当我尝试运行npm install时遇到了问题。 So when I try npm install , it says that I need to run it as root or adminisrator:因此,当我尝试npm install ,它说我需要以 root 或管理员身份运行它:

Error: EACCES, mkdir '/usr/local/lib/node_modules/coffee-script'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/coffee-script']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/coffee-script',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/coffee-script',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ 'DirWriter._create                 (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:297:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

But when try to run it as sudo, it says the following:但是当尝试以 sudo 运行它时,它会显示以下内容:

npm WARN cannot run in wd [email protected] npm install -g coffee-script node-gyp (wd=/home/ubuntu/PackNode)

In my package.json, it contains the following scripts:在我的 package.json 中,它包含以下脚本:

"scripts": {
    "preinstall": "npm install -g coffee-script node-gyp",
    "start": "node server.js",
    "test": "mocha --require should --compilers coffee:coffee-script --colors"
 },

The rest of devdependencies are valid since I have been installing it all right on my own machine (Mac) Does anyone have a clue why this is happening?其余的 devdependencies 是有效的,因为我一直在我自己的机器(Mac)上安装它,有没有人知道为什么会发生这种情况?


解决方案:

参考一: https://en.stackoom.com/question/1E6CA
参考二: https://stackoom.com/question/1E6CA
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章