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

[question] how to update npm for local project #953

Open
unickq opened this issue May 2, 2023 · 7 comments
Open

[question] how to update npm for local project #953

unickq opened this issue May 2, 2023 · 7 comments

Comments

@unickq
Copy link

unickq commented May 2, 2023

Hey,

Switching from Volta, looking for a way to pin npm version for the project.

fnm install 14
node --version > .node-version

node -v
v14.21.3

npm -v
6.14.18

Can the latest npm pin to the project somehow?
Running npm install -g npm@8 from the project dir doesn't work.

@sambauers
Copy link

Use corepack by enabling it after installing a new Node version:

$ corepack enable

And in your package.json specify the package manager and version you want:

{
  ...
  "packageManager": "[email protected]",
  ...
}

Corepack will automatically install and use the version you specify. Not sure if Corepack is available for Node 14 though.

@mikicho
Copy link

mikicho commented Feb 5, 2024

@sambauers
It's working for me for pnpm, but not for npm.
Seems like the symlink for npm is incorrect. I'm not sure if this bug is from fnm or corepack side.
image

@mikicho
Copy link

mikicho commented Feb 5, 2024

Ok.
It seems like this is from corepack side: nodejs/corepack#138

I'm wondering if we need to add --corepack-enabled-all option
WDYT?

@sambauers
Copy link

Right, I wasn't aware until now that corepack doesn't support npm.

Maybe setting the npm version in "engines" inside package.json will help here, and then non-corepack logic will take care of it.

@mikicho
Copy link

mikicho commented Feb 6, 2024

@sambauers it supports npm|. Just not by default. You need to run corepack enable --all`

@sambauers
Copy link

It doesn't officially support it. I can't see a way to hook in to fnm to be able to run that command. It needs to be a feature request for the author I think.

@mikicho
Copy link

mikicho commented Feb 6, 2024

@Schniz WDYT about this?
Another option is to add an install hook

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

3 participants