How to match NodeJS version with compatible package - node.js

I have to run NodeJS app in very old nodejs (version 8.17) and I can't do an update (it is embed in industrial computer with dependencies on this version of node). When I do my regular yarn add express sqlite3 ... and run my app, error apperas
node-pre-gyp info This Node instance does not support builds for Node-API version 6
My question is, can I somehow force yarn/npm to install compatible package version or at least, match node version with compatible package version and install them manually after that?
Thank you for your answers.

Related

Cannot download node-sass binding

If you're using node-sass you might get an error message like this when running npm install:
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.13.1/win32-x64-83_binding.node
Cannot download "from https://github.com/sass/node-sass/releases/download/v4.13.1/win32-x64-83_binding.node":
HTTP error 404 Not Found
The cause of this issue is that in Node there's a concept called ABI (Application Binary Interface) which determines which native modules work with which versions of Node. Since node-sass contains native parts it requires bindings to make it work with different versions of Node. When trying to run npm install the installation fails when attempting to download a binding for your version of Node - which has a too high ABI version. In other words there is no binding for that ABI for node-sass
To solve this:
Uninstall Node
Compare ABI in the list at https://nodejs.org/en/download/releases/ and the mappings available at https://github.com/sass/node-sass/releases for the specific release that you're using
Download and install the latest version of Node which supports your version of node-sass
Delete the node_modules folder and run npm install

The engine "node" is incompatible with this module. Expected version "> 0.4.x < 0.9.0". Got "12.22.1" ? How to solve this

In my react native project I am trying to install dependencies with yarn but for link it says
error link#0.1.5: The engine "node" is incompatible with this module. Expected version "> >0.4.x < 0.9.0". Got "12.22.1"
How can I solve this??
As the error says the dependencies you are installing is only meant to run in node version between 0.4.x to 0.9.0. Version for the dependencies is set by the package developer, this can't be changed.
We can have multiple version of node installed in the machine by using nvm.
nvm can be downloaded from https://github.com/nvm-sh/nvm for linux and macOS, for windows you can download from https://github.com/coreybutler/nvm-windows
But, this would not solve the issue as there would be other packages or library dependency that would depend on higher version of node. Example react-native is supported in node version >=12.0.
Better solution would be to check for higher version of the dependencies. For to find another library that can achieve the desired result.

NPM install the latest available version matching with nodejs version

On my server I am limited to Nodejs version 11.5 and wanted to install some packages there. Clearly the latest version of the packages does not work on the old Node version. Is there any way to tell npm to install an older version which matches with our Nodejs version? I want a way to automatically find the installable version of package and don't want to use trial and error to find the working package.
Thanks

Can't create new Angular project

Installed the Angular CLI using this command
npm install -g #angular/cli
But when creating new project using command
ng new PROJECT-NAME
it shows
You are running version v8.0.0 of Node.js, which is not supported by
Angular CLI v6. The official Node.js version that is supported is
8.9 and greater. Please visit https://nodejs.org/en/ to find instructions on how to update Node.js.
But actually i am using nodejs v9.11.1
See screenshot of my cli
Mostly sounds like a version problem. The new angular cli version requires the latest version of node.
All you need to do is update node and npm to latest version , everything should work fine.
If you are working on windows I'd suggest just going on their site and getting the latest one(currently at the time of this post is 8.11.2). For linux based and mac I would suggest looking for a guide how to get latest version since installing from terminal with something like (apt-get install or yum) will not have latest version you need (can easily be changed with some simple commands)
Also do check the version of node with: node -v
There has also been a naming conflict on linux regarding node vs nodejs see this question.

In Angular how can check node version and show message during the npm install if installed version not matched with specifed version

I am trying to define validation which check the node and cli version with specified version before going to install package.json dependencies.
Example: Suppose when I started my angular project the node and cli version was 5.2.1 and now they are updated 5.2.6 or 5.3.* but I don't want to run my app on updated version so how can I show alert/error message and exit that user who are going to install the app and there package dependencies

Resources