环境
Windows 10 Home
节点V10.13.0
NPM 6.4.1
所需的行为
更新所有节点软件包。
实际行为
并非所有软件包都在更新。
我尝试了
npm update
在这篇文章中的每个信息:
npm安装与更新 - 有什么区别?
在运行npm update
之前:
$ npm outdated
Package Current Wanted Latest Location
babel-loader 7.1.4 7.1.5 8.0.5 my_folder
bcrypt 3.0.0 3.0.4 3.0.4 my_folder
body-parser 1.18.2 1.18.3 1.18.3 my_folder
clipboard 2.0.1 2.0.4 2.0.4 my_folder
cors 2.8.4 2.8.5 2.8.5 my_folder
css-loader 0.28.11 0.28.11 2.1.0 my_folder
date-fns 1.29.0 1.30.1 1.30.1 my_folder
dompurify 1.0.8 1.0.10 1.0.10 my_folder
express 4.16.3 4.16.4 4.16.4 my_folder
file-loader 1.1.11 1.1.11 3.0.1 my_folder
file-saver 1.3.8 1.3.8 2.0.1 my_folder
helmet 3.13.0 3.15.1 3.15.1 my_folder
hotkeys-js 3.3.8 3.4.4 3.4.4 my_folder
jsonwebtoken 8.2.1 8.5.0 8.5.0 my_folder
less 3.0.4 3.9.0 3.9.0 my_folder
mongodb 3.1.6 3.1.13 3.1.13 my_folder
nodemailer 4.6.8 4.7.0 5.1.1 my_folder
socket.io 2.1.1 2.2.0 2.2.0 my_folder
style-loader 0.21.0 0.21.0 0.23.1 my_folder
uglifyjs-webpack-plugin 1.2.5 1.3.0 2.1.2 my_folder
uikit 3.0.0-rc.24 3.0.3 3.0.3 my_folder
url-loader 1.0.1 1.1.2 1.1.2 my_folder
validator 10.8.0 10.11.0 10.11.0 my_folder
webpack 4.19.1 4.29.6 4.29.6 my_folder
webpack-cli 2.1.5 2.1.5 3.2.3 my_folder
package.json
在运行npm update
之前:
"dependencies": {
"bcrypt": "^3.0.0",
"body-parser": "^1.18.2",
"clipboard": "^2.0.1",
"cors": "^2.8.4",
"date-fns": "^1.29.0",
"dompurify": "^1.0.8",
"express": "^4.16.3",
"file-saver": "^1.3.8",
"helmet": "^3.13.0",
"hotkeys-js": "^3.3.8",
"jquery": "^3.3.1",
"js-cookie": "^2.2.0",
"jsonwebtoken": "^8.2.1",
"markdown-it": "^8.4.2",
"markdown-it-attrs": "^2.3.2",
"mongodb": "^3.1.6",
"nodemailer": "^4.6.8",
"rename-keys": "^2.0.1",
"socket.io": "^2.1.1",
"validator": "^10.8.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"css-loader": "^0.28.11",
"expose-loader": "^0.7.5",
"file-loader": "^1.1.11",
"less": "^3.0.4",
"less-loader": "^4.1.0",
"style-loader": "^0.21.0",
"uglifyjs-webpack-plugin": "^1.2.5",
"uikit": "^3.0.0-rc.24",
"url-loader": "^1.0.1",
"webpack": "^4.19.1",
"webpack-cli": "^2.1.5"
}
运行npm update
:
$ npm outdated
Package Current Wanted Latest Location
babel-loader 7.1.5 7.1.5 8.0.5 my_folder
css-loader 0.28.11 0.28.11 2.1.0 my_folder
file-loader 1.1.11 1.1.11 3.0.1 my_folder
file-saver 1.3.8 1.3.8 2.0.1 my_folder
nodemailer 4.7.0 4.7.0 5.1.1 my_folder
style-loader 0.21.0 0.21.0 0.23.1 my_folder
uglifyjs-webpack-plugin 1.3.0 1.3.0 2.1.2 my_folder
webpack-cli 2.1.5 2.1.5 3.2.3 my_folder
运行npm update
时,为什么这些软件包不更新到最新版本?
如何将它们更新为最新版本?
上下文
我已经离开了一个开发项目大约3个月了,尝试在本地机器上运行npm start
时会出现错误:
Error: EPERM: operation not permitted, open 'C:UsersMeAppDataRoamingnpmnode_modulesnodemonnode_modulesflatmap-streamindex.min.js'
看来event‑stream
节点软件包已被"劫持"(请参阅此处的相关GitHub问题)。
我的防病毒程序BitDefender确实删除了有问题的文件:
Item was deleted.
Threat name:
Trojan.Agent.DQGP.
C:UsersMeAppDataRoamingnpmnode_modulesnodemonnode_modulesflatmap-streamindex.min.js
因此,我决定更新所有节点软件包,以期将有问题的软件包删除并更新为最新的"清洁"版本。
它的行为方式。
如果您查看您提到的"未更新"的包装,并参考package.json
中各自的条目,则可以看到它们带有^
(Caret Operator)的前缀,只会将它们更新为最近的主要版本(第一个数字的)。
例如,如果您采用软件包 babel-loader
,则包含包的 "^7.1.4"
版本。babel-loader
'S ^7.x.x的最新主要版本是=> 7.1.5
您可以在此处检查版本历史记录(babel-loader
)=> https://www.npmjs.com/package/babel-loader/v/8.0.0.0.0.0.0-beta.1
以上适用
css-loader
file-loader
file-saver
nodemailer
style-loader
uglifyjs-webpack-plugin
webpack-cli
希望这会有所帮助!