Skip to content

Instantly share code, notes, and snippets.

@k8adev
Created November 23, 2023 11:31
Show Gist options
  • Save k8adev/8b3c8c13c396b60c606e4a11ef01f41a to your computer and use it in GitHub Desktop.
Save k8adev/8b3c8c13c396b60c606e4a11ef01f41a to your computer and use it in GitHub Desktop.
npm 8
  • Node.js Compatibility: npm 8 is included with Node.js 16 and is expected to be included with Node.js 17. It drops support for Node.js 10, which is no longer maintained.

  • Package Lockfile Format: npm 8 uses package-lock.json format v2 by default, which is backwards compatible with npm 7.

  • Override Option: npm 8 introduces the --override option, which allows you to individually override the configurations in the .npmrc files.

  • Updated Dependencies: npm 8 updates many dependencies and removes others, which can lead to different behaviors and new features.

  • Strict Peer Dependencies: npm 7 introduced automatic installation of peer dependencies, which continues in npm 8. However, npm 8 has made this installation stricter. If a package cannot be installed due to a conflicting peer dependency, npm 8 will block the installation.

  • Workspaces: Both npm 7 and 8 support workspaces, a set of features that provide support to manage multiple packages within a single top-level, root package. However, npm 8 has made several improvements and bug fixes to workspaces.

  • Newly Added Commands: npm 8 has added new commands like npm exec (an alias for npm run-script), npm set-script, npm fund, and npm diff.

  • Deprecations: npm 8 has deprecated several commands and features, like npx, npm cache clean, and others.

Updating

To update npm from version 7 to version 8, you can use the following command in your terminal:

npm install -g npm@8

This command tells npm to globally install the latest version of npm in the 8.x.x range.

Before running this command, make sure you have the necessary permissions to install global packages. If you encounter permission errors, you might need to prefix the command with sudo (on Linux or macOS), or run it in an Administrator command prompt (on Windows).

As for changes in your project, here are a few things you might need to consider:

Peer Dependencies: npm 8 has made the installation of peer dependencies stricter. If a package cannot be installed due to a conflicting peer dependency, npm 8 will block the installation. You might need to resolve these conflicts in your project.

Deprecations: npm 8 has deprecated several commands and features, like npx, npm cache clean, and others. If your project relies on these features, you might need to update your scripts or configurations.

New Features: npm 8 introduces new features like workspaces and the --override option. You might want to update your project to take advantage of these features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment