运行 `npm -g outdated` 时跳过一个包

Posted

技术标签:

【中文标题】运行 `npm -g outdated` 时跳过一个包【英文标题】:Skip a package when running `npm -g outdated` 【发布时间】:2021-10-01 16:55:20 【问题描述】:

我有一个手动更新的包,以便运行同一工具的多个版本(如 here 所述)。

现在,当我执行npm -g outdated 时,我得到以下输出:

$ npm -g outdate                         
npm notice 
npm notice New minor version of npm available! 7.18.1 -> 7.20.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.20.1
npm notice Run npm install -g npm@7.20.1 to update!
npm notice 
npm ERR! code ENOVERSIONS
npm ERR! No versions available for ask-cli-1

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/b/.npm/_logs/2021-07-24T13_02_50_529Z-debug.log

这里是日志的内容,为简洁而编辑:

0 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', '-g', 'update' ]
1 info using npm@7.18.1
2 info using node@v16.4.1
...
9 timing config:load:file:/usr/local/lib/node_modules/ask-cli-1/.npmrc Completed in 0ms
...
33 silly fetch manifest ask-cli-1@*
34 http fetch GET 200 https://registry.npmjs.org/ask-cli-1 38ms (cache hit)
...
40 silly placeDep ROOT ask-cli-1@ OK for:  want: *
...
316 timing idealTree:node_modules/ask-cli-1 Completed in 0ms
...
1338 verbose stack ask-cli-1: No versions available for ask-cli-1
1338 verbose stack     at pickManifest (/usr/local/lib/node_modules/npm/node_modules/npm-pick-manifest/index.js:140:25)
1338 verbose stack     at module.exports (/usr/local/lib/node_modules/npm/node_modules/npm-pick-manifest/index.js:187:16)
1338 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/pacote/lib/registry.js:118:26
1338 verbose stack     at async Arborist.[nodeFromEdge] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:936:19)
1338 verbose stack     at async Arborist.[buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:882:11)
1338 verbose stack     at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
1338 verbose stack     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:134:5)
1338 verbose stack     at async Update.update (/usr/local/lib/node_modules/npm/lib/update.js:72:5)
1339 verbose cwd /usr/local/lib/node_modules/ask-cli-1
1340 verbose Darwin 20.5.0
1341 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "-g" "update"
1342 verbose node v16.4.1
1343 verbose npm  v7.18.1
1344 error code ENOVERSIONS
1345 error No versions available for ask-cli-1
1346 verbose exit 1

有没有办法避免npm 寻找ask-cli-1 的版本?

【问题讨论】:

【参考方案1】:

您不能排除 npm 已过期的包。

但我推荐这个包:check-outdated

在你的情况下npm i -g check-outdated 然后: check-outdated --ignore-packages ask-cli-1 --columns name,type,current,latest,changes

【讨论】:

以上是关于运行 `npm -g outdated` 时跳过一个包的主要内容,如果未能解决你的问题,请参考以下文章

马文。运行测试时跳过插件执行

maven打包时跳过测试

maven打包时跳过测试

Ansible - 当至少一个项目在循环中失败时跳过任务

为啥 IntelliJ 在远程调试时跳过断点

将推特数据导入熊猫时跳过属性错误