检查 package.json 是否包含不在 node_modules 中的依赖项
我正在寻找一种方法来检查是否有需要安装但当前尚未安装的软件包.例如,存在先前未安装的 package.json 依赖项或先前未安装的 package.json 依赖项版本.需要明确的是,我不是在寻找过时的软件包.
I'm looking for a way to check if there are packages that need to be installed that currently are not. For example, there is a package.json dependency that was not previously installed or a package.json dependency version that was not previously installed. To be clear, I'm not looking for outdated packages.
如果这是不可能的,我会知道 npm install
是否安装或删除了任何软件包.
If this is not possible, I would be ok with knowing whether npm install
installed or removed any packages.
尝试使用 --dry-run 标志
.根据文档 man npm-install
:
Try using the --dry-run flag
. According to the docs man npm-install
:
The --dry-run argument will report in the usual way what the
install would have done without actually installing anything.
您可以运行此命令,检查输出.不幸的是,根据是否有任何变化,返回值看起来并没有变化,但您可以解析输出.
You can run this command, check the output. Unfortunately, it doesn't look like the return value changes depending on whether there are any changes, but you can parse the output.
如果输出的最后一行看起来像:
If the last line of the output looks like:
up to date in 7.064s
那么你很好,但如果它看起来像:
Then you are good, but if it looks like:
added 1 package in 7.014s
或
updated 1 package in 6.019s
然后需要一个 npm i.
Then an npm i is required.