Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v9.x FAQ #5844

Closed
lukekarrys opened this issue Nov 10, 2022 · 7 comments
Closed

v9.x FAQ #5844

lukekarrys opened this issue Nov 10, 2022 · 7 comments
Assignees

Comments

@lukekarrys
Copy link
Contributor

lukekarrys commented Nov 10, 2022

🎉 npm i npm -g will now install npm@9 🎉

Breaking Changes

Migration Guide

Installing symlinked local dependencies

npm@9 changed the default value of install-links from false to true.

This means that npm will now attempt to install directories by default instead of symlinking them.

Note that workspaces will always be symlinked, so the latest workspaces changes will always be reflected in your package.

How to turn it off

You can run the following to set the previous behavior on a per-project basis:

npm config set install-links=false --location project

Compatibility with npm@6

npm@9 changed the lockfile-version for new projects from 2 to 3.

If you are creating a new project and want to maintain compatibility with npm@6 you will need to downgrade your lockfile-version to 2. Existing projects will not have their lockfile-version number changed.

To set a project specific lockfile-version run:

npm config set lockfile-version=2 --location project

Known Issues

ENOENT package.json Errors

Note:
If you get this error, try running the command with --install-links=false

npm@9 has changed the default of the install-links flag to true. This means that when running npm install with a directory as the argument (such as npm install ../path/to/local-package), npm will attempt to install that directory into the node_modules/ directory just like any other package, instead of creating a symlink like it would previously.

We are tracking a fix (ref: #5820) for a known issue where transitive local directory dependencies can cause this error.

Workaround

To workaround this issue, run either of the following:

  • npm install --install-links=false to run a single install that will create symlinks
  • npm config set install-links=false --location project to set this as a default for your project in its local .npmrc file

Other Issues

If you find other issues with v9, use the Bug v9 Issue Template to open a new issue.

@lukekarrys
Copy link
Contributor Author

Added items in the body of this issue for how to maintain lockfile compatibility with npm@6 and continue installing local dependencies as symlinks.

@shifenhutu
Copy link

do we have any plan to support creates hard links from the global store to the project's folders.

like pnpm

https://pnpm.io/faq#why-does-my-node_modules-folder-use-disk-space-if-packages-are-stored-in-a-global-store

@ljharb
Copy link
Contributor

ljharb commented Mar 23, 2023

@hutuyishi https://github.com/npm/rfcs/blob/main/accepted/0042-isolated-mode.md already exists for symlinks; i'm not sure if hard links are planned since they add a lot of complexity, especially across platforms.

@jmcelroy58
Copy link

Is npm login still supported in v9.x?

@yjhmelody
Copy link

When will package.json support comment just like tsconfig.json

@ljharb
Copy link
Contributor

ljharb commented Aug 31, 2023

@yjhmelody that would be a bad idea prior to node supporting serializing and deserializing such a format.

@rondales

This comment has been minimized.

@lukekarrys lukekarrys unpinned this issue May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants
@ljharb @lukekarrys @yjhmelody @jmcelroy58 @shifenhutu @rondales and others