在处理 Node.js 项目时,我运行npm install
命令。事情发生了,最后我收到了这条消息:
╭────────────────────────────────────────────────────────────────╮
│ │
│ New patch version of npm available! 6.13.4 → 6.13.7 │
│ Changelog: https://github.com/npm/cli/releases/tag/v6.13.7 │
│ Run npm install -g npm to update! │
│ │
╰────────────────────────────────────────────────────────────────╯
认为更新到最后一个版本总是好的,我运行(按照建议):
Shell-Prompt$ npm install -g npm
......
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/bin-links
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/env-paths
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/get-caller-file
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/invert-kv
......
可以看出有几个问题。除了我不明白为什么会遇到这些写访问问题之外;确实没有建议以 root 身份运行命令(或类似建议);我继续尝试:
Shell-Prompt$ sudo 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-bin.1
npm ERR! dest /usr/local/share/man/man1/npm-bin.1
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../../../lib/node_modules/npm/man/man1/npm-bin.1' -> '/usr/local/share/man/man1/npm-bin.1'
npm ERR! File exists: /usr/local/share/man/man1/npm-bin.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/me/.npm/_logs/2020-02-18T02_57_36_473Z-debug.log
跑步:
Shell-Prompt$ rm /usr/local/share/man/man1/npm-bin.1
只会使 npm 不可用。
把它们加起来。遵循补丁建议的方法是什么?
npm 的新补丁版本可用!6.13.4 → 6.13.7
不用遇到这么多麻烦。