ホーム > Other > How to Upgrade the Default npm Version in nvm
Other

How to Upgrade the Default npm Version in nvm

Thank you for your continued support.
This article contains advertisements that help fund our operations.

This article explains how to upgrade the default npm version after upgrading npm with nvm.

Conclusion

nvm use 16

Note: "16" is a placeholder for the desired version. You can replace it with the version you need.

Running this command switches the Node.js version to 16 in your current shell. This works for local environments or on EC2 instances.

For more details, refer to the documentation.

When You Need This Command

When switching Node.js versions using nvm, after running:

nvm install 16

This command installs Node.js version 16.*, but multiple versions may remain installed in the environment.

To set the current shell to use Node.js version 16, simply run:

nvm use 16

An Alternative Tool

Another JavaScript version management tool is Volta, which I personally use more often. One of its main advantages is that Volta allows you to manage versions per project using package.json, reducing the hassle of switching versions in the terminal for different projects.

For example, by running the pin command like this:

volta pin node@20
volta pin node@20.18.0

It will add the following configuration to your package.json, making it easy to share and enforce the same settings across the project for all team members:

"volta": {
  "node": "20.18.0",
  "npm": "10.**.**"
}

Summary

That’s it! I hope you found this helpful.

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!