8

whenever I am starting my Node app it's giving following error.

Error: Failed to replace env in config: ${NPM_TOKEN}
at /usr/local/lib/node_modules/npm/lib/config/core.js:429:13
at String.replace (native)
at envReplace (/usr/local/lib/node_modules/npm/lib/config/core.js:424:12)
at parseField (/usr/local/lib/node_modules/npm/lib/config/core.js:400:7)
at /usr/local/lib/node_modules/npm/lib/config/core.js:338:17
at Array.forEach (native)
at Conf.add (/usr/local/lib/node_modules/npm/lib/config/core.js:337: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:325:10)
at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16



/usr/local/lib/node_modules/npm/lib/npm.js:29
throw new Error('npm.load() required')
^

Error: npm.load() required
at Object.npm.config.get (/usr/local/lib/node_modules/npm/lib/npm.js:29:11)
at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:58:40)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:387:3)
at emitOne (events.js:77:13)
at process.emit (events.js:169:7)
at process._fatalException (node.js:224:26)

Plz provide any solution. I totally stucked with this.Due to this issue I am unable to start my app and complete my work.

Ritu Gupta
  • 507
  • 2
  • 8
  • 22
  • For me it was because of private packages I had and did not configure NPM_TOKEN env var – Armen Jun 18 '17 at 17:57
  • 1
    Possible duplicate of [NPM - Failed to replace env in config: ${NPM\_TOKEN}](https://stackoverflow.com/questions/52015748/npm-failed-to-replace-env-in-config-npm-token) – luator Apr 25 '19 at 08:54

1 Answers1

0
  • Temporary remove file .npmrc with your ${NPM_TOKEN}
  • Switch to proper node version ( with node version manager you can run like nvm use 12 )
  • export your environment variable "export NPM_TOKEN=yourvalue"
  • move back your .npmrc file and try to run your project again!