sqllite3 install on node and macos give error - node.js

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

Related

Installing dependencies with npm-peer-dependencies

I am trying to install the required node_modules for a small project running Angular 11 using npm install
My goal is get the project to work locally after downloading it from GitHub. I have already installed the latest version of the Angular CLI.
After running the install command I tried npm start.
I was expecting that after running the install and start command to be able to run the project locally.
However the actual result I get after running the install command is the following list of errors:
> ng serve
An unhandled exception occurred: Cannot find module '#angular/compiler'
Require stack:
\node_modules\#angular\compiler-cli\index.js
\node_modules\#ngtools\webpack\src\angular_compiler_plugin.js
\node_modules\#ngtools\webpack\src\index.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\typescript.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\index.js
\node_modules\#angular-devkit\build-angular\src\browser\index.js
\node_modules\#angular-devkit\build-angular\src\dev-server\index.js
\node_modules\#angular-devkit\architect\node\node-modules-architect-host.js
\node_modules\#angular-devkit\architect\node\index.js
\node_modules\#angular\cli\models\architect-command.js
\node_modules\#angular\cli\commands\serve-impl.js
\node_modules\#angular-devkit\schematics\tools\export-ref.js
\node_modules\#angular-devkit\schematics\tools\index.js
\node_modules\#angular\cli\utilities\json-schema.js
\node_modules\#angular\cli\models\command-runner.js
\node_modules\#angular\cli\lib\cli\index.js
\node_modules\#angular\cli\lib\init.js
\node_modules\#angular\cli\bin\ng
See "angular-errors.log" for further details.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file C:\WINDOWS\system32\cmd.exe
npm ERR! errno ENOENT
npm ERR! `ng serve`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the #0.0.16 start 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:
The problem is that this Angular project also has peer dependencies. I installed npm-install-peers package but it seems that simply running npm install afterwards will not install the required peer dependencies.
What should I do next to get this Angular project installed locally ?
The issue you are facing is likely because angular cli or npm-peer-dependencies are not installed globally on your machine.
The steps that you should take are to make sure of them are globally installed.
To install packages globally you need run npm install -g <package_name>
npm docs link
In your case for angular cli you should run
npm i -g #angular/cli#11.2.15 and npm install -g npm-peer-dependencies.
Then run npm start.

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

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

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

NodeJS "npm update -g npm" fails with "Error: Refusing to delete" (Installed via package, NOT homebrew)

While trying to fix a JPG compatibility issue, I'm running into the following error when trying to update npm on my Mac OSX (Yosemite). Note that I did not install via homebrew, instead via the official package. (I'm using version 0.10.37 to counteract yet another NPM package issue).
Here are the steps I take:
brew uninstall node and brew uninstall npm to be triple-sure Node is not present on my system via Homebrew. The output is as expected, Error: No such keg: /usr/local/Cellar/node
Download the package from http://nodejs.org/dist/v0.10.37/ and install it.
node -v to verify that Node is installed.
npm update -g npm
And here's the output from that last command:
$ npm update -g npm
npm ERR! Refusing to delete: /usr/local/share/man/man3/npm-bin.3 not in /usr/local/lib/node_modules/npm
File exists: /usr/local/share/man/man3/npm-bin.3
Move it away, and try again.
npm ERR! System Darwin 14.1.0
npm ERR! command "node" "/usr/local/bin/npm" "update" "-g" "npm"
npm ERR! cwd /Users/topher
npm ERR! node -v v0.10.37
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/share/man/man3/npm-bin.3
npm ERR! code EEXIST
npm ERR! error rolling back Error: Refusing to delete: /usr/local/share/man/man3/npm-bin.3 not in /usr/local/lib/node_modules/npm
npm ERR! error rolling back at clobberFail (/usr/local/lib/node_modules/npm/lib/utils/gently-rm.js:57:12)
npm ERR! error rolling back at next (/usr/local/lib/node_modules/npm/lib/utils/gently-rm.js:43:14)
npm ERR! error rolling back at /usr/local/lib/node_modules/npm/lib/utils/gently-rm.js:52:12
npm ERR! error rolling back at Object.oncomplete (evalmachine.<anonymous>:108:15)
npm ERR! error rolling back { [Error: Refusing to delete: /usr/local/share/man/man3/npm-bin.3 not in /usr/local/lib/node_modules/npm] code: 'EEXIST', path: '/usr/local/share/man/man3/npm-bin.3' }
npm ERR! not ok code 0
When I delete the above mentioned file and try again, I get another error because the npm command no longer exists. It looks like the update partially succeeded in that the npm command was deleted:
$ npm
-bash: /usr/local/bin/npm: No such file or directory
When I search for this "Refusing to delete" error, I see tons of advice for how to fix a botched Homebrew install (plus some unnecessarily condescending instructions on how to remove the Homebrew package. But I'm not installing the package via homebrew; the advice I'm finding there doesn't seem relevant in my case.
How should I go about troubleshooting this? Anyone else know of / have this problem / can think of a quick fix?
Thanks in advance!
This isn't a complete answer, but just to follow up I found a way to work around this issue.
My ultimate need was to get node running with the package resemble installed. Resemble relies on cairo, which was installed via homebrew; it seems that this was my first mistake. Because Cairo was apparently improperly installed, a couple packages were missing; this forced me to use one workaround that triggered other errors and required other workarounds... and so forth.
When I removed the Cairo homebrew package and instead built Cairo from source (using this guide), several other errors I was having just melted away.
So the lesson I'm learning is: Don't use Homebrew for anything finnicky, or for any dependencies of anything finnicky.
I solve it by this:
rm /usr/bin/npm
/usr/lib64/node_modules/npm/bin/npm-cli.js install npm -g
npm -v # success !

Resources