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

Cannot set store-dir in NPM v9 #5621

Closed
jandolezal71 opened this issue Nov 11, 2022 · 13 comments · Fixed by #5829
Closed

Cannot set store-dir in NPM v9 #5621

jandolezal71 opened this issue Nov 11, 2022 · 13 comments · Fixed by #5829
Assignees
Milestone

Comments

@jandolezal71
Copy link

jandolezal71 commented Nov 11, 2022

pnpm version: 7.15.0

https://pnpm.io/configuring

Code to reproduce the issue:

nvm install 16.18
npm install pnpm@latest
pnpm config set store-dir .pnpm-store

Expected behavior:

npm will set `store-dir=.pnpm-store` to `.npmrc` file

Actual behavior:

npm ERR! `store-dir` is not a valid npm option
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-11-11T08_10_13_758Z-debug-0.log

Experimental

On npm version 7 or 8, it works.

npm install -g npm@8
npm -v # 8.19.3
pnpm config set store-dir /path/to/.pnpm-store
npm config list

# store-dir = "/path/to/.pnpm-store"

Log

32 info config set "store-dir" "/path/to/.pnpm-store"
33 timing command:config Completed in 3ms
34 verbose stack Error: `store-dir` is not a valid npm option
34 verbose stack     at Config.set (/usr/local/lib/node/lib/node_modules/npm/lib/commands/config.js:163:15)
34 verbose stack     at Config.exec (/usr/local/lib/node/lib/node_modules/npm/lib/commands/config.js:125:22)
34 verbose stack     at Npm.exec (/usr/local/lib/node/lib/node_modules/npm/lib/npm.js:187:29)
34 verbose stack     at async module.exports (/usr/local/lib/node/lib/node_modules/npm/lib/cli.js:133:5)
35 verbose cwd /
36 verbose Linux 5.13.0-52-generic
37 verbose node v16.18.1
38 verbose npm  v9.1.1
39 error `store-dir` is not a valid npm option
40 verbose exit 1

Additional information:

  • node -v prints: 16.18.1
  • npm -v prints: 9.1.1
  • Windows, macOS, or Linux?: linux
@jandolezal71 jandolezal71 changed the title Cannot set store-dir on NodeJS 16.18 Cannot set store-dir on NPM 9 (default in NodeJS 16.18) Nov 11, 2022
@jandolezal71 jandolezal71 changed the title Cannot set store-dir on NPM 9 (default in NodeJS 16.18) Cannot set store-dir on NPM 9 Nov 11, 2022
@jandolezal71 jandolezal71 changed the title Cannot set store-dir on NPM 9 Cannot set store-dir in NPM 9 Nov 11, 2022
@jandolezal71 jandolezal71 changed the title Cannot set store-dir in NPM 9 Cannot set store-dir in NPM v9 Nov 11, 2022
@zkochan zkochan pinned this issue Nov 11, 2022
@zkochan
Copy link
Member

zkochan commented Nov 11, 2022

This is bad. Looks like we won't be able to just use npm for managing settings.

@jandolezal71
Copy link
Author

This is bad. Looks like we won't be able to just use npm for managing settings.

Maybe cooperate with NPM team to allow custom key/value with some prefix?

@zkochan
Copy link
Member

zkochan commented Nov 14, 2022

It is hard to cooperate with the npm team. They are very slow and not flexible. It will be easier to implement our own pnpm config commands.

@egeorges92
Copy link

I use a hack to solve this issue, using echo to the npmrc file :

echo 'store-dir=/some/path/.pnpm-store' >> /usr/local/etc/npmrc

Hope it's help.

@lvqq
Copy link
Member

lvqq commented Nov 15, 2022

It will be easier to implement our own pnpm config commands

Will this be part of pnpm v8?

@zkochan
Copy link
Member

zkochan commented Nov 15, 2022

I would add it sooner under a feature flag.

@sphtd
Copy link

sphtd commented Nov 28, 2022

I would add it sooner under a feature flag.

Hey, any changes maybe?

@matzeeable
Copy link

See also: npm/cli#5852 (comment)

No this was very much intentional and npm is going to be moving even further in the direction of not allowing invalid configs. None of these would be looked at by npm or any of its submodules anyways.

@JunQu
Copy link

JunQu commented Dec 18, 2022

same problem
npm config set will no longer accept deprecated or invalid config options, I downgrade npm 9 to 8, seems don't work well with npm 9.

@sorashi
Copy link

sorashi commented Dec 19, 2022

This is now very current, because node v19.3.0 (released 5 days ago) ships with npm 9 by default, whereas node v19.2.0 still shipped with npm 8. See https://nodejs.org/en/download/releases/

I had the same problem because of this. I used the node:current-alpine docker image (my mistake, should have pinned the version) inside CI with pnpm config set store-dir to cache the store over stages. CI jobs failed because of this.

Anyone else having this problem, for now use node:19.2.0-*.

@zkochan
Copy link
Member

zkochan commented Dec 23, 2022

For now npm config get returns the values of unknown settings. So it is enough if we implement just the pnpm config set command.

@simpros
Copy link

simpros commented Jun 27, 2023

this is still broken with node:latest image in gitlab ci

@flybywind
Copy link

I use a hack to solve this issue, using echo to the npmrc file :

echo 'store-dir=/some/path/.pnpm-store' >> /usr/local/etc/npmrc

Hope it's help.

similiar here, I edit the /opt/homebrew/lib/node_modules/npm/npmrc in my Mac to add the new line of the key-value. Seems $HOME/.npmrc also works

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

Successfully merging a pull request may close this issue.

10 participants