我几乎没有使用NPM的经验,我在试图获得opensource project (brigadehub)并在本地运行时遇到了一些麻烦。
我刚刚使用macports安装了NPM(我安装了NPM4端口),cd
'd进入该项目的目录,运行npm install -g brigadehub
并出现此错误:
│ ... [millions of these packages]
│
├── user-home@2.0.0
└─┬ validate-npm-package-license@3.0.1
├─┬ spdx-correct@1.0.2
│ └── spdx-license-ids@1.2.2
└── spdx-expression-parse@1.0.4
npm WARN mongoose-schema-to-graphql@2.4.6 requires a peer of graphql@>=0.7.1 but none was installed.
npm ERR! Darwin 14.5.0
npm ERR! argv "/opt/local/bin/node" "/opt/local/bin/npm" "install" "-g" "brigadehub"
npm ERR! node v6.9.5
npm ERR! npm v4.2.0
npm ERR! path /opt/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/opt/local/lib/node_modules'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, access '/opt/local/lib/node_modules'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/opt/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
我看到/ opt / local / lib / node_modules的权限错误并不奇怪 - 我很确定这是由sudo权限下的macports创建的。所以我给了自己整个目录的所有权:
~/sites/codeforbtv.github.com (master)$ sudo chown -R myuser:wheel /opt/local/lib/node_modules
Password:
~/sites/codeforbtv.github.com (master)$ ls -al /opt/local/lib/node_modules
total 0
drwxr-xr-x 3 myuser wheel 102 Feb 25 13:05 .
drwxr-xr-x 201 root admin 6834 Feb 25 12:43 ..
drwxr-xr-x 27 myuser wheel 918 Feb 25 12:59 npm
我已经在我的用户和sudo下重试了npm install命令,但是我得到了相同的响应,我不知道这意味着什么:/
~/sites/codeforbtv.github.com (master)$ npm install -g brigadehub
npm WARN deprecated yarn@0.17.10: It is recommended to install Yarn using the native installation method for your environment. See https://yarnpkg.com/en/docs/install
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
npm WARN deprecated babel-preset-es2015-node4@2.1.1: Use npmjs.org/babel-preset-env instead, see https://github.com/babel/babel-preset-env
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated mongodb@1.3.23: Please upgrade to 2.2.19 or higher
/opt/local/lib
└── (empty)
npm WARN mongoose-schema-to-graphql@2.4.6 requires a peer of graphql@>=0.7.1 but none was installed.
npm ERR! Darwin 14.5.0
npm ERR! argv "/opt/local/bin/node" "/opt/local/bin/npm" "install" "-g" "brigadehub"
npm ERR! node v6.9.5
npm ERR! npm v4.3.0
npm ERR! path /opt/local/lib/node_modules/brigadehub/make start
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/opt/local/lib/node_modules/brigadehub/make start'
npm ERR! enoent ENOENT: no such file or directory, chmod '/opt/local/lib/node_modules/brigadehub/make start'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
我已经确认,确实没有brigadehub的目录。
~/sites/codeforbtv.github.com (master)$ ls -al /opt/local/lib/node_modules
total 0
drwxr-xr-x 3 myuser wheel 102 Feb 25 13:05 .
drwxr-xr-x 201 root admin 6834 Feb 25 12:43 ..
drwxr-xr-x 27 myuser wheel 918 Feb 25 12:59 npm
它应该能够创建它想要的任何目录。那么什么是NPM试图在这里告诉我?