NPM安装失败 [英] npm install failing

查看:159
本文介绍了NPM安装失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会说,我旁边有没有经验,在终端或node.js中工作开始

同事离开度假,我想跟着他离开了我们的演示服务器上设置自己的应用的说明。我能得到的一切在本地运行,但我遇到了安装socket.io模块在服务器上的问题。

安装Python,安装的NodeJS,无论是成功的。但后来我发出命令:

  NPM安装-g socket.io

和输出我得到的是:

  NPM HTTP GET https://registry.npmjs.org/socket.io
NPM HTTP 304 https://registry.npmjs.org/socket.io
NPM ERR!错误:EACCES,MKDIR/usr/local/lib/node_modules/socket.io
NPM ERR! {[错误:EACCES,MKDIR/usr/local/lib/node_modules/socket.io']
NPM ERR!错误号:3,
NPM ERR! code:'EACCES',
NPM ERR!路径:'/usr/local/lib/node_modules/socket.io',
NPM ERR! fstream_type:目录,
NPM ERR! fstream_path:/usr/local/lib/node_modules/socket.io',
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!请重试运行此命令,作为根/管理员。NPM ERR! Linux系统2.6.32-279.el6.x86_64
NPM ERR!命令在/ usr / local / bin目录/节点,在/ usr / local / bin目录/故宫,安装,-gsocket.io
NPM ERR! CWD /家庭/ QA
NPM ERR!节点-v v0.8.16
NPM ERR! NPM -v 1.1.69
NPM ERR!路径/usr/local/lib/node_modules/socket.io
NPM ERR! fstream_path /usr/local/lib/node_modules/socket.io
NPM ERR! fstream_type目录
NPM ERR! fstream_class DirWriter
NPM ERR! code EACCES
NPM ERR!错误号3
NPM ERR!堆栈错误:EACCES,MKDIR/usr/local/lib/node_modules/socket.io
NPM ERR! fstream_stack DirWriter._create(/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)
NPM ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
NPM ERR! fstream_stack Object.oncomplete(fs.js:297:15)
NPM ERR!
NPM ERR!其他记录详细信息可以发现:
NPM ERR! /home/qa/npm-debug.log
NPM ERR!不正常code 0

我在帐户应具有管理员权限。周围的Googling我发现了一些建议,但似乎没有为我工作。试图prepending命令使用sudo但得到的:

  [QA @ UMR-演示〜]须藤NPM安装-g socket.io
对于QA [须藤]密码:
须藤:NPM:命令未找到


解决方案

我有同样的错误,如果没有特权,因此,使用 -g 标志时,我必须使用sudo

如果须藤不recongize NPM你可以试试:


  • 经过故宫的完整路径

      $ sudo的$(其中NPM)安装-g socket.io


  • $ P $与-E标志pserving环境

      $ sudo的-E NPM安装-g socket.io


UPD:

注意,建议使用 -g 标记的仅可执行文件,并在本地(没有标志)安装是库要求 D在code。特权都需要复制的可执行文件的/ usr / bin中或者,你的情况的/ usr / local / bin目录

请注意过,在socket.io网站,不包括用于安装命令 -g 标志;)

了解更多:<一href=\"http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/\">http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/

I'll start off by saying that I have next to no experience working in terminal or with node.js.

Coworker left for vacation and I'm trying to follow instructions he left for setting up his app on our demo server. I can get everything running locally, but am running into issues on the server installing socket.io module.

Installed python, installed nodejs, both successful. But then I issue the command:

npm install -g socket.io

And the output I get is:

npm http GET https://registry.npmjs.org/socket.io
npm http 304 https://registry.npmjs.org/socket.io
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/socket.io'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/socket.io']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/socket.io',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/socket.io',
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.

npm ERR! System Linux 2.6.32-279.el6.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "socket.io"
npm ERR! cwd /home/qa
npm ERR! node -v v0.8.16
npm ERR! npm -v 1.1.69
npm ERR! path /usr/local/lib/node_modules/socket.io
npm ERR! fstream_path /usr/local/lib/node_modules/socket.io
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/socket.io'
npm ERR! fstream_stack DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:297:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/qa/npm-debug.log
npm ERR! not ok code 0

The account I'm on should have admin privileges. Googling around I found some suggestions but none seemed to work for me. Tried prepending command with sudo but get:

[qa@umr-demo ~]sudo npm install -g socket.io
[sudo] password for qa:
sudo: npm: command not found

解决方案

I have the same error if not privileged, so I must use sudo when using the -g flag

If sudo don't recongize npm you can try:

  • passing the complete route of npm

    $ sudo $(which npm) install -g socket.io
    

  • preserving the environment with -E flag

    $ sudo -E npm install -g socket.io
    

Upd:

Note that is recommended to use the -g flag only for executables and install locally (without the flag) the libraries that are required in your code. Privileges are required for copying the executables to /usr/bin or, in your case /usr/local/bin

Note too that in the socket.io site, the -g flag is not included for the installation command ;)

Read more: http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/

这篇关于NPM安装失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆