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

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!

Related

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

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/

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.

RangeError: Invalid array buffer length Error - Reaction Commerce Installation

I am trying to install reaction commerce (reactioncommerce.com) in Google Compute engine with f1-micro (1 vCPU, 0.6 GB memory) server configuration. I am getting while starting the reaction commerce in gcloud shell.
Please guide me what i should do.
zenmonk#eshop::~/reaction reaction init shop
Cloning the master branch of Reaction from Github...
Cloning into 'shop'...
Installing NPM packages...
npm WARN deprecated tough-cookie#2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
dtrace-provider#0.6.0 install /home/zenmonk/reaction/shop/node_modules/dtrace-provider
node scripts/install.js
fibers#1.0.13 install /home/zenmonk/reaction/shop/node_modules/fibers
node build.js || nodejs build.js
linux-x64-v8-4.5 exists; testing
Binary is fine; exiting
reaction#0.14.2 postinstall /home/zenmonk/reaction/shop
.reaction/scripts/postinstall.sh
reaction#0.14.2 /home/zenmonk/reaction/shop
Reaction successfully installed!
To start your Reaction instance, just run:
cd shop
reaction
zenmonk#eshop#:~/reaction/shop$ reaction
Using settings file at settings/dev.settings.json
Setting up plugin imports...
[[[[[ ~/reaction/shop ]]]]]
=> Started proxy.
=> Started MongoDB.
buffer.js:25
const ui8 = new Uint8Array(size);
^
RangeError: Invalid array buffer length
at new ArrayBuffer (native)
at new Uint8Array (native)
at createBuffer (buffer.js:25:17)
at allocate (buffer.js:96:12)
at new Buffer (buffer.js:56:12)
at increaseBufferIfNecessary (/home/zenmonk/.meteor/packages/meteor-tool/.1.4.0-1.13j49n2++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/stream-buffers/lib/writable_streambuffer.js:58:23)
at [object Object].write (/home/zenmonk/.meteor/packages/meteor-tool/.1.4.0-1.13j49n2++os.linux.x8664+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/stream-buffers/lib/writable_streambuffer.js:65:5)
at doWrite (streamwritable.js:300:12)
at writeOrBuffer (streamwritable.js:286:5)
at [object Object].Writable.write (streamwritable.js:214:11)
at Request.ondata (stream.js:31:26)
at emitOne (events.js:82:20)
at Request.emit (events.js:169:7)
at IncomingMessage. (/home/zenmonk/.meteor/packages/meteor-tool/.1.4.0-1.13j49n2++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/request/request.js:1255:12)
at emitOne (events.js:77:13)
at IncomingMessage.emit (events.js:169:7)
at readableAddChunk (streamreadable.js:153:18)
at IncomingMessage.Readable.push (streamreadable.js:111:10)
at HTTPParser.parserOnBody (httpcommon.js:124:22)
at TLSSocket.socketOnData (httpclient.js:320:20)
at emitOne (events.js:77:13)
at TLSSocket.emit (events.js:169:7)
at readableAddChunk (streamreadable.js:153:18)
at TLSSocket.Readable.push (streamreadable.js:111:10)
at TLSWrap.onread (net.js:536:20)
This was wrong with me too and I solved the problem by increasing the computer's memory
this issue is identical to your
RangeError: Invalid array buffer length - Meteor JS

phantomjs-pdf not work

I'm using phantomjs-pdf in my sailsjs app. This code working fine in my local machine(ubuntu 14.0). but server machine(ubuntu 12.0) cause error, like below
internal/child_process.js:274
var err = this._handle.spawn(options);
^
TypeError: Bad argument
at TypeError (native)
at ChildProcess.spawn (internal/child_process.js:274:26)
at exports.spawn (child_process.js:339:9)
at Object.exports.execFile (child_process.js:141:15)
at /var/www/test/node_modules/phantomjs-pdf/lib/phantomjs-pdf.js:83:16
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:721:13
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:52:16
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:269:32
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:44:16
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:718:17
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:167:37
at async.series.paperFormat (/var/www/test/node_modules/phantomjs-pdf/lib/phantomjs-pdf.js:51:70)
at /var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:713:13
at Immediate.iterate [as _onImmediate] (/var/www/test/node_modules/phantomjs-pdf/node_modules/async/lib/async.js:262:13)
at processImmediate [as _immediateCallback] (timers.js:371:17)
This is my error. Any one tell me what is the problem. help me.
Uninstall all NPM packages and then reinstall NPM packages.

Can not create nodester account

I want to register on http://nodester.com/. I got my coupon, registered on site, installed nodester (npm install nodester-cli -g)
and user setup command (nodester user setup gio.beri#gmail.com pass***) gives me error:
nodester info verifying credentials
/usr/local/lib/node_modules/nodester-cli/node_modules/nodester-api/node_modules/request/vendor/cookie/index.js:45
: url.parse(req.url).pathname;
^
TypeError: Cannot read property 'url' of undefined
at new Cookie (/usr/local/lib/node_modules/nodester-cli/node_modules/nodester-api/node_modules/request/vendor/cookie/index.js:45:20)
at /usr/local/lib/node_modules/nodester-cli/node_modules/nodester-api/node_modules/request/main.js:432:33
at Array.forEach (native)
at Request. (/usr/local/lib/node_modules/nodester-cli/node_modules/nodester-api/node_modules/request/main.js:426:46)
at Request.emit (events.js:64:17)
at IncomingMessage. (/usr/local/lib/node_modules/nodester-cli/node_modules/nodester-api/node_modules/request/main.js:391:16)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at CleartextStream.ondata (http.js:1231:22)
at CleartextStream._push (tls.js:303:27)
Can anyone suggest anything?
EDIT:
I think that problem is in my password. what must me there coupon???

Resources