环境
Windows 10 Home
节点v10.13.0
NPM 6.4.1
期望的行为
更新所有节点程序包。
实际行为
并非所有软件包都正在更新。
我尝试过的事情
gen.sh
中的每则信息:
npm install vs. update - what's the difference?
在运行npm update
之前:
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
时这些软件包没有更新为最新版本?
如何将它们更新到最新版本?
上下文
我已经离开开发项目大约3个月了,当尝试在本地计算机上运行npm update
时出现错误:
npm start
似乎Error: EPERM: operation not permitted, open 'C:\Users\Me\AppData\Roaming\npm\node_modules\nodemon\node_modules\flatmap-stream\index.min.js'
节点程序包已被“劫持”(请参阅相关的github issue here)。
我的防病毒程序Bitdefender确实删除了有问题的文件:
event‑stream
因此,我决定更新所有节点程序包,以希望删除有问题的程序包并将其更新为最新的“干净”版本。
答案 0 :(得分:1)
它的行为符合预期。
如果您查看被提及为“未更新”的软件包,并参考它们在package.json
中的相应条目,则可以看到它们以^
为前缀(插入符号运算符),只会将其更新为最新的主版本(第一个数字)。
例如,如果您使用软件包babel-loader
,则package.json带有标记为"^7.1.4"
的版本。 babel-loader
的^ 7.X.X的最新主要版本是=> 7.1.5
您可以在此处查看(babel-loader
的版本历史== https://www.npmjs.com/package/babel-loader/v/8.0.0-beta.1
以上内容适用于其他所有以package.json中的^开头的包,例如
css-loader
file-loader
file-saver
nodemailer
style-loader
uglifyjs-webpack-plugin
webpack-cli
希望这会有所帮助!