不能运行npm install from nvm,但使用https://nodejs.org/en/download/源



需要帮助。几天后,我收到了这样的错误。

➜  online-test-api git:(master) ✗ npm install firebase
npm ERR! code EPERM
npm ERR! errno EPERM
npm ERR! FetchError: request to https://registry.npmjs.org/firebase failed, reason: connect EPERM 104.16.23.35:443 - Local (0.0.0.0:0)
npm ERR!     at ClientRequest.<anonymous> (/Users/ba-00011110/.nvm/versions/node/v12.18.4/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:315:20)
npm ERR!     at TLSSocket.socketErrorListener (_http_client.js:426:9)
npm ERR!     at TLSSocket.emit (events.js:315:20)
npm ERR!     at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR!     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:84:21)
npm ERR!  FetchError: request to https://registry.npmjs.org/firebase failed, reason: connect EPERM 104.16.23.35:443 - Local (0.0.0.0:0)
npm ERR!     at ClientRequest.<anonymous> (/Users/ba-00011110/.nvm/versions/node/v12.18.4/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:315:20)
npm ERR!     at TLSSocket.socketErrorListener (_http_client.js:426:9)
npm ERR!     at TLSSocket.emit (events.js:315:20)
npm ERR!     at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR!     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
npm ERR!   type: 'system',
npm ERR!   errno: 'EPERM',
npm ERR!   code: 'EPERM'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ba-00011110/.npm/_logs/2021-03-08T04_24_07_318Z-debug.log
➜  online-test-api git:(master) ✗

操作系统及版本:MacOS Mojave 10.14.6

npm调试日志

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/ba-00011110/.nvm/versions/node/v12.18.4/bin/node',
1 verbose cli   '/Users/ba-00011110/.nvm/versions/node/v12.18.4/bin/npm',
1 verbose cli   'install',
1 verbose cli   'firebase'
1 verbose cli ]
2 info using npm@6.14.5
3 info using node@v12.18.4
4 verbose npm-session 46594150c17a7289
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for firebase@latest request to https://registry.npmjs.org/firebase failed, reason: connect EPERM 104.16.23.35:443 - Local (0.0.0.0:0)
8 timing stage:rollbackFailedOptional Completed in 0ms
9 timing stage:runTopLevelLifecycles Completed in 265ms
10 verbose type system
11 verbose stack FetchError: request to https://registry.npmjs.org/firebase failed, reason: connect EPERM 104.16.23.35:443 - Local (0.0.0.0:0)
11 verbose stack     at ClientRequest.<anonymous> (/Users/ba-00011110/.nvm/versions/node/v12.18.4/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
11 verbose stack     at ClientRequest.emit (events.js:315:20)
11 verbose stack     at TLSSocket.socketErrorListener (_http_client.js:426:9)
11 verbose stack     at TLSSocket.emit (events.js:315:20)
11 verbose stack     at emitErrorNT (internal/streams/destroy.js:92:8)
11 verbose stack     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:84:21)
12 verbose cwd /Users/ba-00011110/Projects/Nodejs/online-test-api
13 verbose Darwin 18.7.0
14 verbose argv "/Users/ba-00011110/.nvm/versions/node/v12.18.4/bin/node" "/Users/ba-00011110/.nvm/versions/node/v12.18.4/bin/npm" "install" "firebase"
15 verbose node v12.18.4
16 verbose npm  v6.14.5
17 error code EPERM
18 error errno EPERM
19 error FetchError: request to https://registry.npmjs.org/firebase failed, reason: connect EPERM 104.16.23.35:443 - Local (0.0.0.0:0)
19 error     at ClientRequest.<anonymous> (/Users/ba-00011110/.nvm/versions/node/v12.18.4/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
19 error     at ClientRequest.emit (events.js:315:20)
19 error     at TLSSocket.socketErrorListener (_http_client.js:426:9)
19 error     at TLSSocket.emit (events.js:315:20)
19 error     at emitErrorNT (internal/streams/destroy.js:92:8)
19 error     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
19 error     at processTicksAndRejections (internal/process/task_queues.js:84:21)
19 error  FetchError: request to https://registry.npmjs.org/firebase failed, reason: connect EPERM 104.16.23.35:443 - Local (0.0.0.0:0)
19 error     at ClientRequest.<anonymous> (/Users/ba-00011110/.nvm/versions/node/v12.18.4/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
19 error     at ClientRequest.emit (events.js:315:20)
19 error     at TLSSocket.socketErrorListener (_http_client.js:426:9)
19 error     at TLSSocket.emit (events.js:315:20)
19 error     at emitErrorNT (internal/streams/destroy.js:92:8)
19 error     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
19 error     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
19 error   type: 'system',
19 error   errno: 'EPERM',
19 error   code: 'EPERM'
19 error }
20 error The operation was rejected by your operating system.
20 error It is likely you do not have the permissions to access this file as the current user
20 error
20 error If you believe this might be a permissions issue, please double-check the
20 error permissions of the file and its containing directories, or try running
20 error the command again as root/Administrator.
21 verbose exit [ 1, true ]

nvm调试输出:

➜  online-test-api git:(master) ✗ nvm debug
nvm --version: v0.37.2
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'ba-00011110'
${HOME}: /Users/ba-00011110
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v12.18.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Applications/Sublime Text.app/Contents/SharedSupport/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:${HOME}/Library/Android/sdk/platform-tools:${HOME}/.composer/vendor/bin:${HOME}/.symfony/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.3 (x86_64-apple-darwin18.0)'
uname -a: 'Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Jan 12 22:04:47 PST 2021; root:xnu-4903.278.56~1/RELEASE_X86_64 x86_64'
checksum binary: 'shasum'
OS version: Mac 10.14.6 18G8022
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin18.0) libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1
wget: /usr/local/bin/wget, GNU Wget 1.20.3 built on darwin18.7.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/bin/git, git version 2.21.1 (Apple Git-122.3)
ls: grep:: No such file or directory
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
nvm current: v12.18.4
which node: ${NVM_DIR}/versions/node/v12.18.4/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v12.18.4/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v12.18.4
npm root -g: ${NVM_DIR}/versions/node/v12.18.4/lib/node_modules
➜  online-test-api git:(master) ✗

nvm ls output:

➜  online-test-api git:(master) ✗ nvm ls
->     v12.18.4
v14.16.0
default -> node (-> v14.16.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.16.0) (default)
stable -> 14.16 (-> v14.16.0) (default)
lts/* -> lts/fermium (-> v14.16.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.0 (-> N/A)
lts/erbium -> v12.21.0 (-> N/A)
lts/fermium -> v14.16.0

$ PATH

# Export Command
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
export PATH="$PATH:/Applications/Sublime Text.app/Contents/SharedSupport/bin"
export PATH="$PATH:/usr/local/bin"
export PATH="$PATH:/usr/local/sbin"
export PATH="$PATH:/usr/local/mysql/bin"
export PATH="$PATH:$HOME/Library/Android/sdk/platform-tools"
# export PATH="$PATH:$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin"
export PATH="$PATH:$HOME/.composer/vendor/bin"
export PATH="$PATH:$HOME/.symfony/bin"

npm配置

➜  online-test-api git:(master) ✗ cat ~/.npmrc
➜  online-test-api git:(master) ✗ npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.6 node/v12.18.4 darwin x64"
; node bin location = /Users/ba-00011110/.nvm/versions/node/v12.18.4/bin/node
; cwd = /Users/ba-00011110/Projects/Nodejs/online-test-api
; HOME = /Users/ba-00011110
; "npm config ls -l" to show all defaults.
➜  online-test-api git:(master) ✗

我已经尝试将配置注册表从https://registry.npmjs.org更改为http://registry.npmjs.org。HTTP在新项目上工作得很好,但这是在我的旧项目上,因为旧项目在package-lock.json上使用HTTPS。我尝试了npm install从手动安装https://nodejs.org/en/download/而且出乎意料地运行良好。我不知道这是NVM或NPM或nodejs或我的机器的问题。

using nvm
npm install => got error like above
using manual install
/path-to-npm install => working well

以上所有进程使用同一连接。有人能帮我吗?这个问题很困扰我。

谢谢所有的

尝试从系统中完全卸载node .js并尝试安装node v12.13.0(您可以从https://nodejs.org/dist/v12.13.0/安装它)

相关内容

  • 没有找到相关文章

最新更新