Git bash doesn't execute npm install - node.js

I keep getting this error in Git Bash when trying to do an npm install:
64 verbose stack Error: command failed
64 verbose stack at ChildProcess.<anonymous> (C:\Users\baseuser\AppData\Roaming\npm\node_modules\npm\node_modules\#npmcli\promise-spawn\index.js:64:27)
64 verbose stack at ChildProcess.emit (events.js:400:28)
64 verbose stack at maybeClose (internal/child_process.js:1058:16)
64 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
65 verbose pkgid app-backend#1.0.1-dev.0
66 verbose cwd C:\work\gitrepo\app-backend
67 verbose Windows_NT 10.0.18363
68 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\baseuser\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
69 verbose node v14.18.0
70 verbose npm v8.0.0
71 error code 1
72 error path C:\work\gitrepo\app-backend
73 error command failed
74 error command C:\windows\system32\cmd.exe /d /s /c npm run build
75 verbose exit 1
I have node and npm installed globally and npm install works in Powershell or Windows Command line, but not in Git Bash for some reason. I have them added to PATH variable. I done npm clear cache -force but nothing changed.
Removed node, npm, git with git bash and reinstalled them againt, and the error still present.

this issue happened recently to many ppl earlier in the last 2 weeks , it seems like a problem withh package distrepution .
To fix this try cloning your library to different location . going into the packages/dscc-scripts directory and running the build command. You can then point all of the scripts from the package.json dscc-gen made to the packages/dscc-scripts/index.js file. Bit of a hack, but good for the quick fix.

Related

npm ERR! Unexpected end of JSON input while parsing near '...ain" : "src/index.js"' while running npm install -g #angular/cli

I get the the above error when I ran the command npm install -g #angular/cli
the complete logs are as below
verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...ain" : "src/index.js"'
78 verbose stack at JSON.parse (<anonymous>)
78 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
78 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
78 verbose stack at processTicksAndRejections (internal/process/task_queues.js:97:5)
79 verbose cwd C:\Users\E079233\Coinnov\CoInnovUI
80 verbose Windows_NT 10.0.17763
81 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "#angular/cli"
82 verbose node v12.18.2
83 verbose npm v6.14.5
84 error Unexpected end of JSON input while parsing near '...ain" : "src/index.js"'
85 verbose exit [ 1, true ]
I tried npm cache clean --force and npm install #angular/cli#latest as suggested in another answer but it didn't work
Please suggest a possible way to fix this issue.
If you stumble upon this thread searching for answers and nothing suggested in other threads has helped you, then maybe the problem is in your private npm registry. As for me it was very slow responding and, as I think, connection closed eventually by timeout causing JSON with package metadata being invalid AND also storing such invalid JSON in npm cache.
The fix for me was to explicitly set registry for packages from our scope:
npm config set #myco:registry http://reg.example.com
This ensures that ONLY your company scope packages are downloaded from set registry, and others are from global registry. Also make sure you don't overwrite this setting by local .npmrc file in your repo root.
It seems you are seeing issues because of npm.
Please try out ::
npm cache clean --force
npm i -g npm
npm i -g #angular/cli#latest
npm i or npm install both are same. Please dont get confused

Facing error code ENOENT syscall rename errno -4058 while trying to install node packages

I've been trying to install several node packages that always lead to the npm ERR (images attached below). I was able to install the express package, but not mongoose, mongodb, #angular/cli, during the installation of which I'm facing this error.
The following are my versions of node and npm
Below is the error log that gets saved.
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'E:\\Nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Nanda\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli '#angular/cli'
1 verbose cli ]
2 info using npm#6.14.5
3 info using node#v12.16.3
4 verbose npm-session aa9c7864071a84f9
.
.
.
75 verbose stack Error: ENOENT: no such file or directory, rename 'C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\tmp\d74359a7' -> 'C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\1a\94\b0bf25ce70e3a557bd2f6e7ce38f87d6e715bf15d505ea7404b7510dcbb9b86427338b5fbf6ee5543c0aa619fab39ec391345cd432372d4c8a7c6bdb6e09'
76 verbose cwd C:\Users\Nanda
77 verbose Windows_NT 6.1.7601
78 verbose argv "E:\\Nodejs\\node.exe" "C:\\Users\\Nanda\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "#angular/cli"
79 verbose node v12.16.3
80 verbose npm v6.14.5
81 error code ENOENT
82 error syscall rename
83 error path C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\tmp\d74359a7
84 error dest C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\1a\94\b0bf25ce70e3a557bd2f6e7ce38f87d6e715bf15d505ea7404b7510dcbb9b86427338b5fbf6ee5543c0aa619fab39ec391345cd432372d4c8a7c6bdb6e09
85 error errno -4058
86 error enoent ENOENT: no such file or directory, rename 'C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\tmp\d74359a7' -> 'C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\1a\94\b0bf25ce70e3a557bd2f6e7ce38f87d6e715bf15d505ea7404b7510dcbb9b86427338b5fbf6ee5543c0aa619fab39ec391345cd432372d4c8a7c6bdb6e09'
87 error enoent This is related to npm not being able to find a file.
88 verbose exit [ -4058, true ]
Note: I'm on a a windows 7, 32-bit system
I had a similar issue and found the following entry on github:
https://github.com/mapbox/node-sqlite3/issues/900
I just deleted the existing node_modules and installed it again with "npm install"

Unable to install StackImpact on Azure Web App

I am unable to install the NodeJs perf monitor "StackImpact" on either of my Azure Web Apps (Windows based running Kudu). It all works fine locally on my Windows 10 laptop but NPM install fails on the servers (output below)
I've tried upgrading to Node 10.6 (latest version Azure supports), then downgrading back to Node 8.11.1. I double checked that the machines are running in 64bit.
...
89 verbose stack Error: stackimpact#1.3.10 install: `node node-gyp-fallback.js`
89 verbose stack Exit status 1
89 verbose stack at EventEmitter.<anonymous> (D:\Program Files (x86)\npm\6.1.0\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)
89 verbose stack at EventEmitter.emit (events.js:182:13)
89 verbose stack at ChildProcess.<anonymous> (D:\Program Files (x86)\npm\6.1.0\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
89 verbose stack at ChildProcess.emit (events.js:182:13)
89 verbose stack at maybeClose (internal/child_process.js:961:16)
89 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
90 verbose pkgid stackimpact#1.3.10
91 verbose cwd D:\home\site\wwwroot
92 verbose Windows_NT 10.0.14393
93 verbose argv "D:\\Program Files (x86)\\nodejs\\10.6.0\\node.exe" "D:\\Program Files (x86)\\npm\\6.1.0\\node_modules\\npm\\bin\\npm-cli.js" "install" "stackimpact"
94 verbose node v10.6.0
95 verbose npm v6.1.0
96 error code ELIFECYCLE
97 error errno 1
98 error stackimpact#1.3.10 install: `node node-gyp-fallback.js`
98 error Exit status 1
99 error Failed at the stackimpact#1.3.10 install script.
99 error This is probably not a problem with npm. There is likely additional logging output above.
100 verbose exit [ 1, true ]
Any help would be greatly appreciated!
soutarm. I reproduce your issue on my side.
According to my observation, it has nothing to do with node version or npm version. It said node-gyp not found.
So, I followed this case to run the command npm install -global node-gyp. You could check it under the D:\local\AppData\npm>.
As we know, node-gyp needs to rely on python2.7 and Microsoft's vc++ build tools for compilation, this is fine on Linux systems because Linux is installed by default, but the Windows operating system does not install python2.7 and vc++ Build tool by default.
I tried to install that npm install --global --production windows-build-tools but failed. It needs admin permission which is can't be touched by us in web app sandbox restrictions.
So,as workaround, maybe you have to install the packages locally then upload total node_modules folder to azure instead of installing packages in kudu.
Addition:
Azure support pointed out that the package only runs in 64 bit environments while their Web Apps run x86 Node by default, even if you've set the environment to x64.
You can override by manually copying x64 Node to the server, updating iisnode.yml to point to it then manually updating node_modules. All of which totally destroys any chance of a clean CI path.

npm ERR! Invalid name: "#types/handlebars"

I was trying to install typedoc with npm, however seeing the following error:
npm ERR! Invalid name: "#types/handlebars"
I then tried to install #types/handlebars directly by:
npm install #types/handlebars
And the same error message shows up again. When I try to view package info by running:
npm info #types/handlebars
I can see the info correctly. What else should I check to tackle the problem?
I am using node v4.8.3 and npm v2.15.11 on OSX 10.10.5.
Here are the stack trace from npm-debug.log:
58 verbose etag https://registry.npmjs.org/#types%2fhandlebars from cache
59 verbose get saving #types/handlebars to /Users/ycchen/.npm/registry.npmjs.org/_40types_252fhandlebars/.cache.json
60 verbose correctMkdir /Users/ycchen/.npm correctMkdir not in flight; initializing
61 silly addNameTag next cb for #types/handlebars with tag latest
62 silly addNamed #types/handlebars#4.0.33
63 verbose addNamed "4.0.33" is a plain semver version for #types/handlebars
64 verbose stack Error: Invalid name: "#types/handlebars"
64 verbose stack at ensureValidName (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:297:15)
64 verbose stack at Object.module.exports.fixNameField (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/fixer.js:201:5)
64 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:29:38
64 verbose stack at Array.forEach (native)
64 verbose stack at normalize (/usr/local/lib/node_modules/npm/node_modules/read-package-json/node_modules/normalize-package-data/lib/normalize.js:28:15)
64 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:349:5)
64 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:5)
64 verbose stack at ReadFileContext.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:295:20)
64 verbose stack at ReadFileContext.callback (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16)
64 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:303:13)
I suspect this has to do with where it is actually getting the types from. The info command works since it must be looking at official npm registry.
To try it out you can override the registry for specific scopes (#types in this case). For example:
npm config set #types:registry https://registry.npmjs.org/
This tells npm to always get anything for the #types scope directly from the official registry.
EDIT: I see from your edited question that npm does try to get it from the official registry so you might wish to get the latest npm since the version you are using is quite dated. You can do so by:
sudo npm cache clean
sudo npm install npm -g

npm install, node-gyp rebuild error

I'm just starting out working with node.js and when I try npm install I get an error stating Failed at the bcrypt#0.8.5 install script 'node-gyp rebuild'. After extensive googling I still have not found the problem.
Here's the error log:
Error Log
313 verbose stack Error: bcrypt#0.8.5 install: `node-gyp rebuild`
313 verbose stack Exit status 1
313 verbose stack at EventEmitter.<anonymous> (C:\Users\Apparaat1\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:239:16)
313 verbose stack at emitTwo (events.js:100:13)
313 verbose stack at EventEmitter.emit (events.js:185:7)
313 verbose stack at ChildProcess.<anonymous> (C:\Users\Apparaat1\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:24:14)
313 verbose stack at emitTwo (events.js:100:13)
313 verbose stack at ChildProcess.emit (events.js:185:7)
313 verbose stack at maybeClose (internal/child_process.js:827:16)
313 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
314 verbose pkgid bcrypt#0.8.5
315 verbose cwd D:\Werk\W12C\we12c\W12C
316 error Windows_NT 6.1.7601
317 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Apparaat1\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
318 error node v5.7.0
319 error npm v3.7.3
320 error code ELIFECYCLE
321 error bcrypt#0.8.5 install: `node-gyp rebuild`
321 error Exit status 1
322 error Failed at the bcrypt#0.8.5 install script 'node-gyp rebuild'.
322 error Make sure you have the latest version of node.js and npm installed.
322 error If you do, this is most likely a problem with the bcrypt package,
322 error not with npm itself.
322 error Tell the author that this fails on your system:
322 error node-gyp rebuild
322 error You can get information on how to open an issue for this project with:
322 error npm bugs bcrypt
322 error Or if that isn't available, you can get their info via:
322 error npm owner ls bcrypt
322 error There is likely additional logging output above.
323 verbose exit [ 1, true ]
Versions:
node -v
v5.7.0
npm -v
3.7.3
May be it's a little bit late but the solution in node-gyp
https://github.com/nodejs/node-gyp#installation
There are 2
different options.
Option 1: Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).
Option 2: Install tools and configuration manually:
Visual C++ Build Environment:
Option 1: Install Visual C++ Build Tools using the Default Install option.
Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.
Install Python 2.7 (v3.x.x is not supported), and run npm config set python python2.7 (or see below for further instructions on specifying the proper Python version and path.)
Launch cmd, npm config set msvs_version 2015
If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.
[Windows Vista / 7 only] requires .NET Framework 4.5.1

Resources