npm install不在乎package-lock.json

时间:2019-09-02 20:00:20

标签: linux jenkins npm package-lock.json

我在jenkins上的npm install安装了package-lock.json中未定义的软件包版本。

当我在Windows上本地运行时,它按预期工作,安装了1.4.10的cleave.js软件包。但是,当我通过jenkins运行它时,它会安装另一个版本1.5.3。

当我检查jenkins构建日志时,看起来它是从缓存的二进制文件中安装软件包的。

Cached binary found at /var/lib/jenkins/.npm/node-sass/4.12.0/linux-x64-57_binding.node
> core-js@2.6.9 postinstall /var/lib/jenkins/workspace/CI-MyProject-Demo/build/exports/MyProject/MyProject-web/node_modules/core-js
> node scripts/postinstall || echo "ignore"

> sauce-connect-launcher@1.2.7 postinstall /var/lib/jenkins/workspace/CI-MyProject-Demo/build/exports/MyProject/MyProject-web/node_modules/sauce-connect-launcher
> node scripts/install.js || nodejs scripts/install.js

> node-sass@4.12.0 postinstall /var/lib/jenkins/workspace/CI-MyProject-Demo/build/exports/MyProject/MyProject-web/node_modules/node-sass
> node scripts/build.js

Binary found at /var/lib/jenkins/workspace/CI-MyProject-Demo/build/exports/MyProject/MyProject-web/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
sfra@4.0.0 /var/lib/jenkins/workspace/CI-MyProject-Demo/build/exports/MyProject/MyProject-web

...
│   └── rimraf@2.7.1 
├── cleave.js@1.5.3 
├─┬ cross-env@5.2.1 
...

现在,我能想到的可能解决方案是我可以删除/var/lib/jenkins/.npm/node-sass/4.12.0/linux-x64-57_binding.node此文件,并且它应该可以工作。但是我不确定这是否会破坏其他任何东西,或者这是否可行。

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

您可以使用

代替删除模块
npm cache clean

在运行安装之前