npm ERR! node-expat#2.3.18 install: `node-gyp rebuild` - node.js

I am new to AWS ec2 instance, I have tried to host my server code on ec2 I have done my instance setup successfully based on the following reference from "https://ourcodeworld.com/articles/read/977/how-to-deploy-a-node-js-application-on-aws-ec2-server".
On the ec2 ubuntu server, I am getting "npm ERR! node-expat#2.3.18 install: node-gyp rebuild" error when I install node-modules using npm I cmd. I have tried many examples from StackOverflow no one solved my issue. The error message is following below
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-expat#2.3.18 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat#2.3.18 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2020-10-03T15_56_49_786Z-debug.log

I found answer for this problem from
https://github.com/astro/node-expat/issues/172

If you're using recent macOS or macs they use Catalina. In that case, use these guidelines to use gyp in macs:
https://github.com/nodejs/node-gyp/blob/main/macOS_Catalina.md
this solved the err for me

This issue bugged me after updating to the macOS Monterey. It could be issue with the python and python version. so check in logs if it is python version not found or mismatch. If the scenario matches then follow below steps:-
$ brew install pyenv
$ pyenv install 3.10.3
$ pyenv global 3.10.3
# Add pyenv to your PATH so that you can reference python
$ echo "export PATH=\"\${HOME}/.pyenv/shims:\${PATH}\"" >> ~/.zshrc
# open a new terminal window and confirm your pyenv version is mapped
$ which python3
$ python3 --version
# Now try to re-run yarn install or npm install

Related

sqllite3 install on node and macos give error

I have a sqllite database (.db) file which I want to connect to using node. I assume I need to use the package sqlite3. However when I try to install this I get the following error
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3#4.2.0 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3#4.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
My node version is 14.3.0. From what I checked I need to use sqlite3 to connect to the .db file. Is there some other package I can use or does anyone know how to fix this error ?
I struggled with this issue on Ubuntu 20.04, node version 14.5.0 until when i came across sqlite3 npm documentation. Simply execute the following commands if you are on Ubuntu 20.04:
sudo apt-get install libsqlite3-dev
Navigate to your project directory and then execute npm i sqlite3

Getting error on angular CLI isntallation

I am trying to install angular/cli on my windows10 64-bit machine, But I am getting the following error:
npm ERR! code ENOGIT
npm ERR! Error while executing:
npm ERR! undefined ls-remote -h -t ssh://git#github.com/angular/cli.git
npm ERR!
npm ERR! undefined
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-03-19T08_13_51_165Z-debug.log
I am trying to execute the following command:
npm install -g angular/cli
Following are the specifications:
node --version
v10.15.1
npm --version
6.4.1
Things tried till now as suggested in different posts and forums:
Tried running command prompt as Administrator
Setting the network settings(set https-proxy and proxy).
npm cache clean --force
I don't have git installed on my machine, but is it necessary and mandatory?
I have installed angular previously also(Angular 4) but at that time everything was fine.
Need help.
You should install #angular/cli (note the #)
npm i #angular/cli
This one does not require git to be installed.
I have to admit that this naming is confusing.

opencv4nodejs installation issue

I am Facing trouble in installing opencv4nodejs in windows, i am getting following error.
opencv-build#0.0.15 install C:\Users\Mypc\AppData\Roaming\npm\node_modules\opencv4nodejs\node_modules\opencv-build
node ./install.js
info install if you want to use an own OpenCV installation set OPENCV4NODEJS_DISABLE_AUTOBUILD
info install library dir does not exist: C:\Users\Mypc\AppData\Roaming\npm\node_modules\opencv4nodejs\node_modules\opencv-build\opencv\build\lib\Release
info install running install script...
ERR! Error: Command failed: git --version
'git' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! opencv-build#0.0.15 install: node ./install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv-build#0.0.15 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
Git was not installed in windows, that was the issue. it's working perfectly now.
Git needs to be installed, it will solve this problem

npm i Running command - failed! (exit code 254)

Ionic :3.20.0
node: v8.10.0
npm: 5.6.0
npm i
✖ Running command - failed!
[ERROR] An error occurred while running npm i (exit code 254):
npm ERR! path
/Users/lucaszimmermann/Desktop/myApp/node_modules/tsickle/src/main.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod
'/Users/lucaszimmermann/Desktop/myApp/node_modules/tsickle/src/main.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR!
/Users/lucaszimmermann/.npm/_logs/2018-04-04T16_41_39_270Z-debug.log
I faced a similar issue after doing the below actions this issue solved.
Delete package-lock.json file.
Open cmd/terminal in administrator mode.
run command: npm install
run command: npm update
Node version is likely incompatible. There'd be an expected version actual version. Use nvm or similar to install and change node versions.
Delete node_modules and try install again. You probably get a message similar to:
error ts-jest#26.1.2: The engine "node" is incompatible with this module. Expected version ">= 10.21.0". Got "10.20.1"
error Found incompatible module.
You wan't try to install npm packages.
You have two options to install some packages:
First Option:
npm install <package>
npm i <package>
Second Option:
If you wan't to create an automated installation process without each package, you must provide an packge.json - Here are all depencies listed. You can only run npm i or npm install without an package name, if you have an package.json
A full documentation about that is on NPM: https://docs.npmjs.com/files/package.json

Install new version of npm and use it instead of the shared one

We are many persons who work on the same server where our projects live. Every one of course has his own virtual environment.
We all share the same node.js v4.4.5 and npm 2.15.5.
However, I need npm >= 3.0.0, so I installed a newer version /usr/local/n/versions/node/8.1.3/bin/npm and I added aliases for node and npm into my ~/.bashrc
# ~/.bashrc
alias node='/usr/local/n/versions/node/8.1.3/bin/node'
alias npm='/usr/local/n/versions/node/8.1.3/bin/npm'
Then I sourced it source ~/.bashrc and I thought it worked because
$ npm --version
5.0.3
Until I run npm run dev
$ npm run dev
> training#1.0.0 dev /home/users/itsme/projects/training
> /usr/local/n/versions/node/8.1.3/bin/node build/dev-server.js
To use this template, you must update following to modules:
npm: 2.15.5 should be >= 3.0.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! training#1.0.0 dev: `/usr/local/n/versions/node/8.1.3/bin/node build/dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the training#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/users/itsme/.npm/_logs/2017-07-06T15_13_11_912Z-debug.log
I don't understand why it seems to be running the shared outdated npm instead of mine.
And here another quite weird thing
$ which npm # shows the shared one
$ `which npm` --version
2.15.5
https://github.com/creationix/nvm
Node version manager makes managing multiple node environments a simple task.
This has solved my problem (based on Oliver Charlesworth's answer)
export PATH="/usr/local/n/versions/node/8.1.3/bin:$PATH"

Resources