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] xxx is not a valid npm option #5852

Closed
2 tasks done
lvqq opened this issue Nov 13, 2022 · 12 comments
Closed
2 tasks done

[QUESTION] xxx is not a valid npm option #5852

lvqq opened this issue Nov 13, 2022 · 12 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release

Comments

@lvqq
Copy link

lvqq commented Nov 13, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Running npm config -g test-key test-value and I get:

npm ERR! `test-key` is not a valid npm option

I am sad with this change since all custom configs cannot be set by running npm config. And is there any plans to remove this limit?

Expected Behavior

npm config works fine while using custom config

Steps To Reproduce

Just run npm config with custom config:
npm config -g set <custom-key> <custom-value>

Environment

  • npm: 9.1.1
  • Node.js: 16.8.1
  • OS Name: MacOS
  • System Model Name: Macbook Pro
@lvqq lvqq added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Nov 13, 2022
@brianunlam
Copy link

I'm having a similar issue.

@wraithgar
Copy link
Member

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.

@axel3rd
Copy link

axel3rd commented Dec 5, 2022

Many NPM modules are using third-part URL for downloading something during installation.
For some NPM usage (for sample: in company), these URLs should be proxified via an internal URL (private network, security reasons, ...).

Currently these configurations are stored in NPM config file => not allow anymore these properties will add complexity in NPM configuration ("manipulate" file manually, environment variables, ...).

I have in mind (--location user not added here, as was done previously for NPM v8):

# phantomJS (https://github.com/Medium/phantomjs#deciding-where-to-get-phantomjs)
npm config set phantomjs_cdnurl http://registry.company.com/some-path/bitbucket/ariya/phantomjs

# node-sass (https://github.com/sass/node-sass#binary-configuration-parameters)
npm config set sass_binary_site http://registry.company.com/some-path-proxify-github/sass/node-sass/releases/download

# cypress (https://docs.cypress.io/guides/references/advanced-installation#Mirroring)
npm config set cypress_download_mirror http://registry.company.com/some-path

# sqlite3 (https://github.com/TryGhost/node-sqlite3/issues/1157)
npm config set node_sqlite3_binary_host_mirror http://registry.company.com/some-path-proxify-github/TryGhost/node-sqlite3/releases/download

# Any modules installed via 'node-pre-gyp' like 'node-libcurl'
npm config set node_libcurl_binary_host_mirror http://registry.company.com/some-path-proxify-github/JCMais/node-libcurl/releases/download

# Chromium via puppeteer
npm config set puppeteer_download_host http://registry.company.com/some-path-proxify-google-storage

@spsaucier
Copy link

This broke our workflow, but since we needed only one npm config var, I just hijacked one that isn't particularly important to NPM: npm config set heading This-is-my-custom-value

@TinaC
Copy link

TinaC commented Mar 28, 2023

Have the same issue when I use npm config set user 0, is there any replacement?
https://timjrobinson.com/fixing-node-gyp-permission-denied-when-running-as-root/

@a-y-u-s-h
Copy link

Have the same issue when I use npm config set user 0, is there any replacement? https://timjrobinson.com/fixing-node-gyp-permission-denied-when-running-as-root/

Have you found an answer to that yet? I can't work without it.

@maxfal
Copy link

maxfal commented Oct 16, 2023

Have the same issue when I use npm config set user 0, is there any replacement? https://timjrobinson.com/fixing-node-gyp-permission-denied-when-running-as-root/

Have you found an answer to that yet? I can't work without it.

Also interested in a solution

@ayushi-dentsu
Copy link

ayushi-dentsu commented Oct 19, 2023

Have the same issue when I use npm config set user 0, is there any replacement? https://timjrobinson.com/fixing-node-gyp-permission-denied-when-running-as-root/

Have you found an answer to that yet? I can't work without it.

Also interested in a solution

has anyone figured out the solution?

@a-y-u-s-h
Copy link

I found the solution to my issue but it's difficult to articulate because it's been a while. If I remember right, it was an issue with read/write permissions of my drive where I had my projects. So in /etc/fstab I changed mount options corresponding to drive which contained projects to comment=x-gvfs-show,nls=utf8,uid=1000,gid=1000,dmask=0000,fmask=0022 and everything worked fine since then.

@CN91
Copy link

CN91 commented Dec 4, 2023

For those still searching for a solution; i worked 'around it' by including a .npmrc with the keys already in there.
Only thing I needed to do was use the .npmrc in my pipeline and use 'sed' to update the file with the pipeline variable

So i was using:

script:
    - npm config set sharp_local_prebuilds $CI_PROJECT_DIR/binaries/sharp/v0.32.6/
    - npm config set sharp_libvips_local_prebuilds $CI_PROJECT_DIR/binaries/libvips/

And now I'm using

a .npmrc file with:

sharp_libvips_local_prebuilds = %PROJECT_DIR%/binaries/libvips/
sharp_local_prebuilds = %PROJECT_DIR%/binaries/sharp/v0.32.6/

And then in the step:

script:
    - cp .gitlab/.npmrc .
    - sed -i 's,%PROJECT_DIR%,'$CI_PROJECT_DIR',g' .npmrc

@brandonfl
Copy link

That's a pretty stupid change, CI pipelines are not working now because many dependencies use variables that we neep to set into the npm config (.npmrc)

Needing to update the .npmrc with bash script when npm config exist is really annoying...

@dante01yoon
Copy link

How do I change distUrl in npm ? what's solution here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

No branches or pull requests