nunomaduro / dd

✨ The most popular way of debugging in PHP is now available in JavaScript.
MIT License
163 stars 7 forks source link

`NPM_TOKEN` in .npmrc #3

Closed eunjae-lee closed 4 years ago

eunjae-lee commented 4 years ago

Any npm command like npm install causes an error like the following:

➜ npm install
Error: Failed to replace env in config: ${NPM_TOKEN}
    at /usr/local/lib/node_modules/npm/lib/config/core.js:415:13
    at String.replace (<anonymous>)
    at envReplace (/usr/local/lib/node_modules/npm/lib/config/core.js:411:12)
    at parseField (/usr/local/lib/node_modules/npm/lib/config/core.js:389:7)
    at /usr/local/lib/node_modules/npm/lib/config/core.js:330:24
    at Array.forEach (<anonymous>)
    at Conf.add (/usr/local/lib/node_modules/npm/lib/config/core.js:328:23)
    at ConfigChain.addString (/usr/local/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
    at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:316:10)
    at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:90:16
/usr/local/lib/node_modules/npm/lib/npm.js:59
      throw new Error('npm.load() required')
      ^

Error: npm.load() required
    at Object.get (/usr/local/lib/node_modules/npm/lib/npm.js:59:13)
    at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:32)
    at process.emit (events.js:196:13)
    at process._fatalException (internal/process/execution.js:142:25)

Then, if I prepend a fake env var, ..

➜ NPM_TOKEN=a npm install
⸨    ░░░░░░░░░░░░░░⸩ ⠙ fetchMetadata: sill removeObsoleteDep removing typescript@3.7.3 from the tree as its been replaced by 

It works 😅

Maybe you should remove .npmrc from repo? I don't know what's the best.

nunomaduro commented 4 years ago

I don't use npm myself, except for the release process here I do setup the NPM_TOKEN on my global env. Thanks for creating the issue tho!

eunjae-lee commented 4 years ago

I wasn't clear. I don't use npm normally, either.

For example, just running yarn lint gets failed because of absence of NPM_TOKEN on my global env. If this is not your personal project, and you're expecting contributions, you'll need to do something about it.

➜ yarn lint
yarn run v1.16.0
error An unexpected error occurred: "Failed to replace env in config: ${NPM_TOKEN}".
info If you think this is a bug, please open a bug report with the information provided in "/Users/eunjaelee/workspace/dd/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
nunomaduro commented 4 years ago

I see! Thanks for sharing.