简体   繁体   English

无法从 nvm 运行 npm 安装,但使用来自 https://nodejs.org/en/download/ 的源代码运行良好

[英]Cannot run npm install from nvm, but working well using source from https://nodejs.org/en/download/

need help.需要帮忙。 in few days i got error like this.几天后我得到了这样的错误。

➜  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) ✗

Operating system and version: MacOS Mojave 10.14.6操作系统和版本: MacOS Mojave 10.14.6

npm debug log 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 debug output: nvm调试output:

➜  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: 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 config 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) ✗

im already trying to change config registry from https://registry.npmjs.org to http://registry.npmjs.org .我已经尝试将配置注册表从https://registry.npmjs.org 更改http://registry.npmjs.org on http working well on new project, but this is beaking on my old project because old project using https on package-lock.json.在 http 上在新项目上运行良好,但这对我的旧项目有影响,因为旧项目在 package-lock.json 上使用 https。 and i've trying npm install from manual install https://nodejs.org/en/download/ .我已经尝试从手动安装npm安装https://nodejs.org/en/download/ and sureprisingly working well.并且肯定运作良好。 i dont know this is issue on nvm or npm or nodejs or my machine.我不知道这是 nvm 或 npm 或 nodejs 或我的机器上的问题。

using nvm
npm install => got error like above

using manual install
/path-to-npm install => working well

all process above using same connection.以上所有过程都使用相同的连接。 anyone can help me?任何人都可以帮助我吗? this issue very disturbing me.这个问题很困扰我。

Thankyou all谢谢你们

Try to completely Uninstall Node.js from the system and try to install node v12.13.0 (You can install it from https://nodejs.org/dist/v12.13.0/ )尝试从系统中完全卸载 Node.js 并尝试安装 node v12.13.0(您可以从https://nodejs.org/dist/v12.13.0/安装它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM