NPM - Failed to replace env in config: ${NPM_BASE64_USERNAME_PASSWORD} - node.js

I'm getting the error below whenever I try to execute anything in my terminal (e.g. npm test or npm install)
I've tried to follow steps similar laid out here - NPM - Failed to replace env in config: ${NPM_TOKEN}. I've also tried setting my username and (encoded) password in my .npmrc file, none of which appear to work for me.
Not really sure what else I should try here ....
Error: Failed to replace env in config: ${NPM_BASE64_USERNAME_PASSWORD}
at /Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:415:13
at String.replace (<anonymous>)
at envReplace (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:411:12)
at parseField (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:389:7)
at /Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:330:24
at Array.forEach (<anonymous>)
at Conf.add (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:328:23)
at ConfigChain.addString (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
at Conf.<anonymous> (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:316:10)
at /Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:123:16
/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/npm.js:59
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.get (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/npm.js:59:13)
at process.errorHandler (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/utils/error-handler.js:208:32)
at process.emit (events.js:375:28)
at process._fatalException (internal/process/execution.js:163:25)

Even, I had encounter the issue similar to thiis while pulling the node component from aws codeartifact via docker file. What you need to do is create a .nmprc file and drop it root location fo the npm installaiton, doing this your issue will get addressed. I was getting below exception while ruinnig npm install in docker file something like
Run powershell -command npm install or any anglar cli install via npm
"8 : RUN powershell -Command npm install
2022-03-03T19:16:34.2653417Z ---> Running in 97791ba93799
2022-03-03T19:16:44.2652033Z [91mError: Failed to replace env in config: ${env:CODEARTIFACT_AUTH_TOKEN}
2022-03-03T19:16:44.2652033Z at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:415:13
2022-03-03T19:16:44.2661894Z at String.replace ()
2022-03-03T19:16:44.2661894Z at envReplace (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:411:12)
2022-03-03T19:16:44.2661894Z at parseField (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:389:7)
2022-03-03T19:16:44.2661894Z at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:330:24
2022-03-03T19:16:44.2661894Z at Array.forEach ()
2022-03-03T19:16:44.2661894Z at Conf.add (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:328:23)"
Solution
please use this docker file, I was passing token from build file something like
Build.ps1
$env:CODEARTIFACT_AUTH_TOKEN = aws codeartifact get-authorization-token --domain se2codepkg --domain-owner 590427636078 --query authorizationToken --output text
docker.ps1
Run powershell echo "registry=https://se2codepkg-590427636078.d.codeartifact.us-east-1.amazonaws.com/npm/npm-store/
//se2codepkg-590427636078.d.codeartifact.us-east-1.amazonaws.com/npm/npm-store/:always-auth=true
//se2codepkg-590427636078.d.codeartifact.us-east-1.amazonaws.com/npm/npm-store/:_authToken=${env:CODEARTIFACT_AUTH_TOKEN}">.npmrc
I got the idea by going through below link
https://developpaper.com/question/after-nodejs-is-installed-successfully-npm-cannot-run-and-prompt-failed-to-replace-env-in-config/

Related

NGCC failed error in Angular 11.x app when running npm run

I have an Angular 11.x app that I run using npm run start - this has worked fine for months but all of a sudden it is no longer running the command and I am getting the following errors, can anyone suggest how I fix this? I have tried the obvious ideas of deleting node_modules and reinstalling them using npm install but with no joy.
Below is the error I get after running npm run start - what have I done to break this :(
Compiling #angular/core : es2015 as esm2015
Error: Error on worker #1: TypeError: Cannot read property 'map' of undefined
at injectDependencies (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler/bundles/compiler.umd.js:6960:21)
at compileFactoryFunction (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler/bundles/compiler.umd.js:6888:61)
at Object.compileInjector (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler/bundles/compiler.umd.js:8106:22)
at NgModuleDecoratorHandler.compileFull (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/src/ngtsc/annotations/src/ng_module.js:427:44)
at _loop_2 (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/src/ngtsc/transform/src/compilation.js:595:39)
at NgccTraitCompiler.TraitCompiler.compile (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/src/ngtsc/transform/src/compilation.js:626:21)
at DecorationAnalyzer.compileFile (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/analysis/decoration_analyzer.js:225:53)
at DecorationAnalyzer.analyzeProgram (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/analysis/decoration_analyzer.js:164:45)
at Transformer.analyzeProgram (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/packages/transformer.js:135:57)
at Transformer.transform (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/packages/transformer.js:77:27)
at ClusterMaster.onWorkerMessage (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/execution/cluster/master.js:195:27)
at /Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/execution/cluster/master.js:55:95
at ClusterMaster.<anonymous> (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/execution/cluster/master.js:293:57)
at step (/Users/zabius/Sites/abc-ui-ng4/node_modules/tslib/tslib.js:143:27)
at Object.next (/Users/zabius/Sites/abc-ui-ng4/node_modules/tslib/tslib.js:124:57)
at /Users/zabius/Sites/abc-ui-ng4/node_modules/tslib/tslib.js:117:75
at new Promise (<anonymous>)
at Object.__awaiter (/Users/zabius/Sites/abc-ui-ng4/node_modules/tslib/tslib.js:113:16)
at EventEmitter.<anonymous> (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/execution/cluster/master.js:287:32)
at EventEmitter.emit (events.js:315:20)
An unhandled exception occurred: NGCC failed.
See "/private/var/folders/b2/1zfdxz293d944p_lxk9_ypz40000gn/T/ng-XQcM3b/angular-errors.log" for further details.
The error in the angular-errors.log file is as follows -
[error] Error: NGCC failed.
at NgccProcessor.process (/Users/zabius/Sites/abc-ui-ng4/node_modules/#ngtools/webpack/src/ngcc_processor.js:129:19)
at /Users/zabius/Sites/abc-ui-ng4/node_modules/#ngtools/webpack/src/angular_compiler_plugin.js:593:31
at SyncHook.eval [as call] (eval at create (/Users/zabius/Sites/abc-ui-ng4/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10$
at SyncHook.lazyCompileHook (/Users/zabius/Sites/abc-ui-ng4/node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
at Object.webpack [as webpackFactory] (/Users/zabius/Sites/abc-ui-ng4/node_modules/webpack/lib/webpack.js:55:30)
at createWebpack (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-webpack/src/webpack-dev-server/index.js:21:36)
at Object.runWebpackDevServer (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-webpack/src/webpack-dev-server/index.js:47:12)
at SwitchMapSubscriber.project (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-angular/src/dev-server/index.js:209:32)
at SwitchMapSubscriber._next (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-angular/node_modules/rxjs/internal/operators/swit$
at SwitchMapSubscriber.Subscriber.next (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-angular/node_modules/rxjs/internal/Subs$
at /Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-angular/node_modules/rxjs/internal/util/subscribeToPromise.js:7:24
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Versions :
npm -v 8.1.0
node -v 14.15.4
Using MacOS BigSur 11.5.2

How do devs maintain old projects?

A year ago I've made a project for a course: https://github.com/GeorgeFlorian/Finished_link_project
Now, I am trying to make it work on my machine, but I have no luck.
I've got npm 7.13.0 and node 16.1.0.
I've ran npm update in order to update all the depencies.
Steps
I've cloned the repo into a PC than runs Linux Mint 20.1
I've ran npm install
npm update
npm run build and npm run serve return the same error:
georgeflorian#georgeflorian-desktop:~/New Volume/VSCode Projects/Finished_link_project$ npm run build
> proiect-link#0.1.0 build
> vue-cli-service build
таз Building for production...
ERROR Failed to compile with 1 error 2:55:41 PM
Syntax Error: TypeError: Cannot read property 'parseComponent' of undefined
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
ERROR Build failed with errors.
I have no idea how to trace the error: Syntax Error: TypeError: Cannot read property 'parseComponent' of undefined.
Also, the NodeJS server won't start:
georgeflorian#georgeflorian-desktop:~/New Volume/VSCode Projects/Finished_link_project/server$ node app.js
node:internal/fs/utils:343
throw err;
^
Error: ENOENT: no such file or directory, stat '/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/dist/favicon.ico'
at Object.statSync (node:fs:1527:3)
at resolveSync (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/node_modules/serve-favicon/index.js:187:17)
at favicon (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/node_modules/serve-favicon/index.js:61:12)
at Object.<anonymous> (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/server/app.js:46:9)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
errno: -2,
syscall: 'stat',
code: 'ENOENT',
path: '/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/dist/favicon.ico'
}
I believe that many dependencies are deprecated, but this begs two questions:
If it worked back then and it hasn't been touched since, why doesn't it work now ?
How can I fix all the deprecated dependencies if npm update did not fix them ?
Ultimately, I would like to learn how to approach this kind of situation. Thank you.

error: A hook (`userconfig`) failed to load

after npm install , getting error like, i have checked every config file and also installed lodash manually after but still not working
error: A hook (`userconfig`) failed to load!
error: Error: In Sails v1.x, `sails.config.globals._` must be either `false` or an object (typically the value of `require('lodash')`)
at Sails.exposeGlobals (D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\exposeGlobals.js:47:44)
at Sails.wrapper [as exposeGlobals] (D:\Node_Project\POS\trunk\node_modules\#sailshq\lodash\lib\index.js:3250:19)
at emitNone (events.js:91:20)
at Sails.emit (events.js:185:7)
at Sails.emitter.emit (D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\after.js:50:11)
at D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\loadHooks.js:111:15
at Hook.initialize (D:\Node_Project\POS\trunk\node_modules\sails\lib\hooks\index.js:154:14)
at Hook.wrapper [as initialize] (D:\Node_Project\POS\trunk\node_modules\#sailshq\lodash\lib\index.js:3250:19)
at D:\Node_Project\POS\trunk\node_modules\sails\lib\hooks\index.js:88:16
at D:\Node_Project\POS\trunk\node_modules\sails\node_modules\async\dist\async.js:486:20
First : Make sure you've installed dependencies with npm install
Second : Check that this app was built for a compatible version of Sails.

unable to start nodejs app- Error: npm.load() required

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.
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!

hubot fails to start with flowdock adapter

node: 0.10.0
npm: 1.2.14
I've set the environment variables HUBOT_FLOWDOCK_LOGIN_EMAIL and HUBOT_FLOWDOCK_LOGIN_PASSWORD, and then tried the following.
Pulled down the prebuilt hubot from the hubot site.
Modified the package.json as above.
Run npm install
Added
"hubot-flowdock": ">= 0.0.1",
just underneath dependencies in my package.json
Removed redis from hubot-scripts.json
run npm install
then running ./bin/hubot -a flowdock -d
With this implementation, ./bin/hubot - flowdock
Produces the following stacktrace:
TypeError: Uncaught, unspecified "error" event.
at TypeError (<anonymous>)
at Session.EventEmitter.emit (events.js:74:15)
at Request._callback (/Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/lib/flowdock.js:49:17)
at Request.self.callback (/Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/node_modules/request/main.js:122:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/node_modules/request/main.js:661:16)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/node_modules/request/main.js:623:14)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:870:14
Looking at /Users/gb/workspace/hubot-2.2.0/node_modules/hubot-flowdock/node_modules/flowdock/lib/flowdock.js:49:17, that is a fail on a response statusCode > 300.
So far so good. Adding a console.log to the line above produces "401" unauthorized.
How? The credentials are correct (I log in with that email/password routinely).
For anyone who cares, eventually I realized that my password was incorrect. I was attempting to use my email password, while the correct answer is to use the password you set up when you first connect to flowdock

Resources