运行npm install -g npm
后,将删除npm
命令。
这是日志:
~
% brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-13.3.0_1.catalina.bottle.tar.gz
Already downloaded: /Users/manabu/Library/Caches/Homebrew/downloads/8a482358c0487b3ffeeebf4d1f3b3ca825018f6318ecdd6368fd0a6f45e0bea1--node-13.3.0_1.catalina.bottle.tar.gz
==> Pouring node-13.3.0_1.catalina.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/node/13.3.0_1: 4,663 files, 59MB
~
% npm install -g npm
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../../../lib/node_modules/npm/man/man1/npm-access.1
npm ERR! dest /usr/local/share/man/man1/npm-access.1
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../../../lib/node_modules/npm/man/man1/npm-access.1' -> '/usr/local/share/man/man1/npm-access.1'
npm ERR! File exists: /usr/local/share/man/man1/npm-access.1
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/manabu/.npm/_logs/2019-12-18T07_51_00_280Z-debug.log
当我运行brew reinstall node
时,我确认再次发生了这种情况。
实际上,正如输出所示,我成功地使用--force
运行它,但是我认为仅显示这些日志比删除npm
命令要好。
编辑(2020/01/11):
实际上,正如输出所示,我成功地用
--force
运行了它
更具体地说,我执行了以下步骤:
npm install -g npm
删除的npm
命令brew reinstall node
来还原它npm install -g --force npm
作为输出与@isaacs的更改相关的https://github.com/npm/cli/commit/320ac9aeeafd11bb693c53b31148b8d10c4165e8 npm / bin-links#12 npm / gentle-fs#7发布于[email protected]
在Homebrew中,npm从6.13.2到6.13.4的颠簸浮出水面https://github.com/Homebrew/homebrew-core/commit/6acc21a27d0ba4ecfd6ebf4d77af7025143daefe#diff -d3ef2414308e30df24a517ca9a1324ee( @pepyinin提交/提交)
AFAICS这是npm中的预期行为。 我不清楚在自制程序中应该如何处理。
https://github.com/npm/cli/issues/672
我做了yarn global add npm
并安装了[email protected]
,但没有遇到错误,但是现在我以前的所有全局包都消失了:((
我退出自制程序,只是使用https://github.com/nvm-sh/nvm
做就是了
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
然后在某个地方,你会看到
=> Compressing and cleaning up git repository
=> Appending nvm source string to /Users/aprilmintacpineda/.bash_profile
=> Appending bash_completion source string to /Users/aprilmintacpineda/.bash_profile
=> Close and reopen your terminal to start using nvm or run the following to use it now:
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
只需source <name of profile>
就我而言<name of profile>
是~/.bash_profile
因此它将是source ~/.bash_profile
然后
nvm install node
安装最新版本的node,它还将安装最新版本的npm,这对我有用。
不知道此线程上的每个人是否都清楚解决方案,因为您知道自己在做什么以及为什么,只是
npm i -g --force npm
(请注意--force
标志)
问题是,在执行npm -I npm并收到错误后,尝试执行任何npm命令都会失败,并显示“ zsh:command not found:npm”,因此即使我想执行--force命令也无法执行。 我必须酿造重新安装节点才能恢复npm。
抱歉,我没有完全描述我如何暂时避免此问题。 我已经更新了说明,请看看。
不知道此线程上的每个人是否都清楚解决方案,因为您知道自己在做什么以及为什么,只是
npm i -g --force npm
(请注意--force
标志)
这是我发现真正解决此问题的唯一解决方案。
这是我第二次在几周内发生这种情况。 您可以使用brew reinstall node
修复它。
这是我运行npm install -g npm
:
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../../../lib/node_modules/npm/man/man1/npm-adduser.1
npm ERR! dest /usr/local/share/man/man1/npm-adduser.1
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../../../lib/node_modules/npm/man/man1/npm-adduser.1' -> '/usr/local/share/man/man1/npm-adduser.1'
npm ERR! File exists: /usr/local/share/man/man1/npm-adduser.1
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/albertvilacalvo/.npm/_logs/2020-01-13T11_55_47_922Z-debug.log
总结的解决方案是:
brew reinstall node
npm i -g --force npm
这不仅发生在自制程序安装中。 我对nodejs安装程序有同样的问题(来自官方网站)。 该修复程序有效,但是...(sudo npm i -g --force npm)
更新npm会删除npm吗? 而且自12月以来还没有固定?
更新npm会删除npm吗? 而且自12月以来还没有固定?
是的,它也发生在MacOS 10.15.2上
刚发生在我身上。 MacOS卡塔利娜10.15.3
这只是在Ubuntu上发生在我身上,我不使用“ brew”。
我最终尝试重新安装npm,但是如果没有sudo,它不会让我安装它。 安装了sudo,然后发现了一个(显然很糟糕)的指南来收回〜/ .npm目录(以及其他几个目录)的所有权。 最初,它仍然不起作用,但是hash -r修复了它(回想起来,重新启动我的Ubuntu也可能起作用)。 这极有可能解决了我的react-snap问题。
此错误已在2014年报告,今天在2020年发生在我身上。真是一场灾难。 这会解决吗?
我退出自制程序,只是使用https://github.com/nvm-sh/nvm
做就是了
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
然后在某个地方,你会看到
=> Compressing and cleaning up git repository => Appending nvm source string to /Users/aprilmintacpineda/.bash_profile => Appending bash_completion source string to /Users/aprilmintacpineda/.bash_profile => Close and reopen your terminal to start using nvm or run the following to use it now: 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
只需
source <name of profile>
就我而言<name of profile>
是~/.bash_profile
因此它将是source ~/.bash_profile
然后
nvm install node
安装最新版本的node,它还将安装最新版本的npm,这对我有用。
如果使用nvm不会发生这种情况
“如果使用nvm,则不会发生”
是的,嗯,如果您也使用yarn
也不会发生,但是我不确定这是否有意义。
我认为这无关紧要。 NVM是节点版本管理器,当我使用brew安装节点时遇到了这种情况,然后切换到nvm,因为那时我还没有经历过。 如果您不知道它是什么,请在此处查看https://github.com/nvm-sh/nvm#installing -and-updating
最有用的评论
总结的解决方案是: