安装 npm 报错

Error message installing npm

当我从根目录键入 npm install 时,我收到以下消息

$ npm install npm ERR! install Couldn't read dependencies npm ERR! Darwin 15.3.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" npm ERR! node v4.4.0 npm ERR! npm v2.14.20 npm ERR! path /package.json npm ERR! code ENOPACKAGEJSON npm ERR! errno -2 npm ERR! syscall open

npm ERR! package.json ENOENT: no such file or directory, open '/package.json' npm ERR! package.json This is most likely not a problem with npm itself. npm ERR! package.json npm can't find a package.json file in your current directory. npm ERR! Darwin 15.3.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" npm ERR! node v4.4.0 npm ERR! npm v2.14.20 npm ERR! path npm-debug.log.3965331654 npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall open

npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.3965331654' npm ERR! at Error (native) npm ERR! { [Error: EACCES: permission denied, open 'npm-debug.log.3965331654'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'open', npm ERR! path: 'npm-debug.log.3965331654' } npm ERR! npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request: npm ERR! /npm-debug.

可能您正在尝试 运行 空目录中的这段代码。这是不对的。 npm install 命令安装 package.json 文件中列出的所有包和依赖项。

如果你想启动npm项目并使npm install运行成功,首先运行npm init命令。这将为您创建 package.json 并且您将能够在其中输入所有包和部门。那么你就可以运行npm install

这是一个tutorial 还有 one 更多