How can I add a .npmrc file?

后端 未结 4 1694
一向
一向 2020-12-12 14:10

I installed node on my Mac OS Sierra. I use Windows at my work so there I have a .npmrc file in the node folder but I don\'t seem to find that in mac. The problem is I want

相关标签:
4条回答
  • 2020-12-12 14:51

    This issue is because of you having some local or private packages. For accessing those packages you have to create .npmrc file for this issue. Just refer the following link for your solution. https://nodesource.com/blog/configuring-your-npmrc-for-an-optimal-node-js-environment

    0 讨论(0)
  • 2020-12-12 14:51

    In MacOS Catalina 10.15.5 the .npmrc file path can be found at

    /Users/<user-name>/.npmrc
    

    Open in it in (for first time users, create a new file) any editor and copy-paste your token. Save it.

    You are ready to go.

    Note: As mentioned by @oligofren, the command npm config ls -l will npm configurations. You will get the .npmrc file from config parameter userconfig

    0 讨论(0)
  • 2020-12-12 15:01

    Assuming you are using VSTS run vsts-npm-auth -config .npmrc to generate new .npmrc file with the auth token

    0 讨论(0)
  • 2020-12-12 15:06

    There are a few different points here:

    1. Where is the .npmrc file created.
    2. How can you download private packages

    Running npm config ls -l will show you all the implicit settings for npm, including what it thinks is the right place to put the .npmrc. But if you have never logged in (using npm login) it will be empty. Simply log in to create it.

    Another thing is #2. You can actually do that by putting a .npmrc file in the NPM package's root. It will then be used by NPM when authenticating. It also supports variable interpolation from your shell so you could do stuff like this:

    ; Get the auth token to use for fetching private packages from our private scope
    ; see http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules
    ; and also https://docs.npmjs.com/files/npmrc
    //registry.npmjs.org/:_authToken=${NPM_TOKEN}
    

    Pointers

    • http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules
    • https://docs.npmjs.com/files/npmrc
    0 讨论(0)
提交回复
热议问题