npm install, node-gyp rebuild error - node.js

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

Related

Git bash doesn't execute npm install

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.

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

npm outdated error Cannot read property 'length' of undefined

I try running 'npm outdated' from the console in my node project. But I get this error:
npm ERR! Cannot read property 'length' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-03-31T12_26_30_745Z-debug.log
This is the error in the log:
199 verbose stack TypeError: Cannot read property 'length' of undefined
199 verbose stack at dotindex (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:59:32)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:11:21
199 verbose stack at Array.forEach (<anonymous>)
199 verbose stack at forEach (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:73:31)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:10:9
199 verbose stack at Array.reduce (<anonymous>)
199 verbose stack at reduce (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:63:30)
199 verbose stack at module.exports (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:9:20)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:130:16
199 verbose stack at cb (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:47:24)
199 verbose stack at outdated_ (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:221:12)
199 verbose stack at skip (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:343:5)
199 verbose stack at updateDeps (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:446:7)
199 verbose stack at tryCatcher (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
199 verbose stack at Promise.successAdapter [as _fulfillmentHandler0] (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\nodeify.js:23:30)
199 verbose stack at Promise._settlePromise (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:566:21)
200 verbose cwd C:\Users\amita\Ionic\toratlechima
201 verbose Windows_NT 10.0.17134
202 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\amita\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "outdated"
203 verbose node v10.11.0
204 verbose npm v6.9.0
205 error Cannot read property 'length' of undefined
206 verbose exit [ 1, true ]
This also happens when I try to run it globally.
Anyone encounter this?
Appears to be fixed in the next release, which isn't out yet.
https://github.com/npm/cli/pull/173
You can install the pre-release to fix it.
npm -g i npm#next
Update
NPM 6.9.2 is out
npm install -g npm
There is a bug in the npm, but you can easily fix it:
Go to your npm folder (i.e. /usr/local/lib/node_modules) and find a outdated.js file (i.e. /usr/local/lib/node_modules/npm/lib/outdated.js for Mac or C:\Users\YOUR_USER_NAME\AppData\Roaming\npm\node_modules\npm\lib\outdated.js for Windows)
Find a function makePretty and change
deppath
to
deppath || 'global'
in my case it was line #152
I hope it helps! 🙂
You can also try npm upgrade -g. Worked for me.
Here's how I successfully fixed the error after checking 'global' was in outdated.js file. Without any other requirements like brew etc, (type these commands in the terminal):
sudo npm cache clean -f (force) clear you npm cache
sudo npm install -g n install n (this might take a while)
sudo n stable upgrade to the current stable version
npm upgrade -g upgrade npm
Note that sudo might prompt your password.

Problem Installing Domino App Dev Pack into Node

I am attempting to install the domino-db module into node:
npm install ./packages/domino-domino-db-1.1.0.tgz --save
Install fails when trying to install grpc 1.14.1 which occurs once a number of other packages have been installed, error message as below.
1209 verbose pkgid grpc#1.14.1
1210 verbose cwd /node_projects/project1
1211 verbose Linux 3.10.0-862.14.4.el7.x86_64
1212 verbose argv "/usr/bin/node" "/bin/npm" "install" "./packages/domino-domino-db-1.1.0.tgz" "--save"
1213 verbose node v11.6.0
1214 verbose npm v6.5.0-next.0
1215 error code ELIFECYCLE
1216 error errno 1
1217 error grpc#1.14.1 install: node-pre-gyp install --fallback-to-build --library=static_library
1217 error Exit status 1
1218 error Failed at the grpc#1.14.1 install script.
1218 error This is probably not a problem with npm. There is likely additional logging output above.
1219 verbose exit [ 1, true ]
NodeJS version is 11.6.0
Does anyone have any idea of the root cause and workaround?
The current version of domino-db was tested and released with Node 8 support (LTS at the time). The next release of domino-db is being tested and released with Node 10 (LTS now) support.
We are aiming to always support the latest LTS releases.

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.

Resources