npm install NOT dowloading latest package

2019-07-14 20:34发布

问题:

[context] I have a problem to use "npm install" command to update my package.json with latest dependencies.

I am running on a Jenkins slave with Multibranch Pipeline, not sure if this is the cause?

There is another post having a similar issue, but not been answered ... NPM package.json not updating after npm install

Here is my package.json

  "dependencies": {
    "@company/ai-integration-test": "^1.0.1-NIGHTLY",
    "@company/ai-portal": "^1.0.1-NIGHTLY",
    "@company/ai-portal-lambdas": "^1.0.1-NIGHTLY"
  }

Here is the result for "npm outdated" [What do I expect]
I would like to get my package.json by running some command if "npm install" is the correct command to use? Thanks a million !!

回答1:

delete your package-lock.json file.

and try npm install again.

But npm install will only update those packages which have "^" in their version, it means auto-update that particular package when you run npm install.



回答2:

I found npm update command helps me to update package.json to the latest available version. But not sure if I am doing the right things though ... inputs are still welcome !! TKS !!

[Final Answer]

It turns out the problem was caused by our company's IT firewall settings. The firewall intermittently forge SSL certificate for security reasons. When that happens, downloading latest package fails without giving error messages.



回答3:

some of those updates are the major release npm update won't update to the latest version.

The major release does not update in this way because they maybe introduce breaking changes. npm save you from that trouble

npm install -g npm-check-updates

then run it:

ncu -u

this will update all packages to the latest version in the package.json