Node-sass Python version compatibility - node.js

I am using 4.14.1 in my project and with Node 14. I need to know which version of Python is needed to run node-gyp.
I also went through the repo link: https://www.npmjs.com/package/node-sass, but not able to find the details of Python version.

Solution
Install and use sass instead of node-sass.
Because node-sass is now deprecated.
npm uninstall node-sass
npm install sass
It works all the same (no additional changes needed)

Change it to sass and remove node-sass

node-gyp requires Python version 2.7, 3.5, or 3.6 to be installed on your system in order to run properly. It is recommended to use the version that is most commonly installed on your system, which is usually 2.7.

Related

npm install doesn't work because of node-sass on ubuntu

I'm trying to npm install a project on Ubuntu but I'm getting this error:
Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (93)
The solutions I found on Stack Overflow was to run npm rebuild node-sass, like in this thread:
Node Sass does not yet support your current environment: Linux 64-bit with false
When I first tried this solution I got this error:
npm - “Can't find Python executable ”python“, you can set the PYTHON env variable.”
and the solution I found for it was to install Python 2.7, from here:
Can't find Python executable "python"
Now when I run python --version I get: Python 2.7.18
So I removed the node_modules folder and the lock file, and run npm install again, but it didn't work, and now I'm getting a build error, which you can find in this gist:
https://gist.github.com/aimad-majdou/b99c5295b56fd5bc68492fa638d63018
I never had issues installing this project on Mac OS and Windows, but this is the first time I try to install it on Ubuntu.
How can I solve this?
There are two solutions for this.
1. Fix python install for npm
You can tell npm to use the correct version of python by running the following command:
npm config set python python2.7
Hopefully after this you can build node-sass.
However, I personally use another solution:
2. Stop using node-sass
There is a pure-javascript sass implementation on npm called sass. It is compatible with node-sass. Just replace node-sass with sass.
Of course, often you did not decide which sass module to use. Usually some framework like React decided to use binary modules like node-sass so you are forced to use it. Well, you can override it in your projcet.
Open your package.json file and edit the node-sass line in the dependencies to:
"dependencies": {
...
"node-sass": "npm:sass#^1.30.0",
...
}
This tells npm to install sass version 1.30.0 as node-sass. Since the sass from the sass module command is compatible with the sass command from node-sass you can now build your project without worrying about building sass. Of course you can use a more recent version of sass if you like.
I see from the gist, that you're running node version 16.x on your ubuntu. As can be seen here, it is probably a version incompatibility between node 16 and the version of node-sass you're trying to build. You should be using at least version 6.0.1 of node-sass for node 16 support.

Unable to downgrade Node to specific version

I am building a sample application in which I need to use Node Version v9.11.2 and npm 4.0.0. Currently I have Node Version v16.4.0 installed on my system. I tried to install the specific version by uninstalling the latest version and installing version 9.11.2 from official website
Problem: The problem is I can uninstall the latest version without any problem but when I try to install older version(9.11.2) the command gets opened and it does nothing. I also tried to install the older version using cli commands ie. npm install -g node#9.11.2, it installs the version but on checking the version using node -v, it still shows the latest version(16.4.0)
Below are the screenshots for better understanding
Installed version 9.11.2 but showing 16.4.0
Any Solution please ?
Is using docker a possibility? If so you can simply get a docker image of the required version and use if from there.
Another way is to use NVM which is a really useful tool to manage nodejs versions. I'm including their github repo for your convenience:
https://github.com/nvm-sh/nvm
A good option is to use NVM: https://github.com/coreybutler/nvm-windows (Windows) or https://github.com/nvm-sh/nvm (unix, macOS). With NVM you can enable different versions of node on the same machine and switch from one to another, usually it takes care of managing the installed packages and adding them to its own management system.

Proper method to get the latest npm on macOS?

When I did npm -v it showed version 7.something.
I just wanted to make sure I have the latest available, so I did npm install -g npm.
It seemed to work OK (it did go through a install/upgrade process) but when I now do npm -v it says 6.14.9.
What is the 'correct' or proper way to get the latest npm on macOS? And I mean in a global way (for my entire coding environment) so that any NodeJS project in any directory will universally use the latest npm.
FYI I'm using macOS Catalina 10.15.6.
npm 7 ships with Node.js 15.x but is not yet the default latest within the npm registry. Confusing! If you want the latest 7.x version of npm, you need to specify that you want version 7: npm install -g npm#7. Otherwise, it will give you the latest 6.x release.
I recommend using nvm to manage your node versions. It allows switching between projects with different versions without running into version issues.
With it, you can use nvm install node to install the latest one, or nvm ls-remote to list available versions for install.

nodejs 4.2.6 not getting updated to latest version

I installed Node and npm as they are required to install angular cli.
Now, if I type this command:
npm install -g angular-cli
I get this message in terminal:
ERROR: npm is known not to run on Node.js v4.2.6 Node.js 4 is supported but the specific version you're running has a bug known to break npm. Please update to at least 4.7.0 to use this version of npm. You can find the latest release of Node.js at https://nodejs.org/
I also followed this link, but still the issue is not resolved.
I tried removing node, npm and then reinstalling, updating node according to all the ways I found on internet, but still the version(4.2.6) is same.
I don't understand what I am doing wrong as I am new to Linux.
Surprisingly, npm is quite complicated in Linux, until you discover Node Version Manager which allows you to easily install new versions and swap between them.
After installing nvm, you can install any node version with nvm install <VERSION_NUMBER> and you can set it as default with nvm alias default <VERSION_NUMBER>
You can swap between versions using nvm use <VERSION_NUMBER>

Angular5 node js and npm installation problems

I have the latest versions of Node and NPM installed, using which I installed Angular/cli, but it's shooting me with following errors: angular/cli and npm versions not compatible with current version of node.
I suspect that I may(not) be installing out of the proper directory. But at this point, what else can I do? thanks.
Please check: Screenshot with details of the issue
I also faced a similar problem, but the solution was quite simple : my path was too long.
I shortened it a bit (two directories down) and then I did the install again with success.
Here are the reqs.
Both the CLI and generated project have dependencies that require Node 6.9.0 or higher, together with NPM 3 or higher.
You are using the latest node.js 9.2
you need to uninstall or rollback to 8.9 !!
Here is a guide
https://github.com/angular/angular-cli
Hope this solves it for you.
I faced a similar problem with angular/cli version not compatible with the current node version. This generally happens when you are upgrading from lower version of Angular to any other higher version.
You can try following steps:
npm outdated --> To list latest and current package details in local application.
npm update --> to update the local packages.
If it still doesn`t work,
Try deleting the 'node_modules' folder and install dependencies of fresh:
npm install
You can then check whether all packages, including the cli is not outdated.

Resources