Failed to "nvm install 8.0.0" - node.js

My goal is to install node version 8 so I can run Gulp on a project.
I'm working on an old project that has been neglected and passed downed to me by another developer. I'm told I can work with Gulp by installing Node Version 8 and declaring the node version in my package.json file.
But whenever I try to run nvm install 8I receive the error error: "unsupported ARM architecture"
My system is MacOS Big Sur M1 Chip
I am not too sure what I'm supposed to do here. Please help!

Solution
The solution was to change the architecture of my shell from arm64 to x86.
Macs with M1 chip
January 2021: there are no pre-compiled NodeJS binaries for versions prior to 15.x for Apple's new M1 chip (arm64 architecture).
Some issues you may encounter:
using nvm to install, say, v14.15.4:
the C code compiles successfully
but crashes with an out of memory error when used
increasing the memory available to node still produces the out of memory errors: $ NODE_OPTIONS="--max-old-space-size=4096" ./node_modules/.bin/your_node_package
when using nvm to install some versions, the compilation fails
One solution to this issue is to change the architecture of your shell from arm64 to x86.
Let's assume that:
you already have versions 12.20.1 and 14.15.4 installed using nvm
the current version in use is 14.15.4
you are using the zsh shell
you have Rosetta 2 installed (macOS prompts you to install Rosetta 2 the first time you open a Intel-only non-command-line application, or you may install Rosetta 2 from the command line with softwareupdate --install-rosetta)
//# Check what version you're running:
$ node --version
v14.15.4
//# Check architecture of the `node` binary:
$ node -p process.arch
arm64
//# This confirms that the arch is for the M1 chip, which is causing the problems.
//# So we need to uninstall it.
//# We can't uninstall the version we are currently using, so switch to another version:
$ nvm install v12.20.1
//# Now uninstall the version we want to replace:
$ nvm uninstall v14.15.4
//# Launch a new zsh process under the 64-bit X86 architecture:
$ arch -x86_64 zsh
//# Install node using nvm. This should download the precompiled x64 binary:
$ nvm install v14.15.4
//# Now check that the architecture is correct:
$ node -p process.arch
x64
//# It is now safe to return to the arm64 zsh process:
$ exit
//# We're back to a native shell:
$ arch
arm64
//# And the new version is now available to use:
$ nvm use v14.15.4
Now using node v14.15.4 (npm v6.14.10)
source: https://github.com/nvm-sh/nvm

Find UR iTerm (or any other termial ur using)
Double-click =>【get info】
In General Panel:
✅ Open using Rosetta (selected this item)
Back to termial and continue use nvm install 8

Related

Installing node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node) error on linux

I have followed this - How to install node.tar.xz file in linux
in the end while doing node --version I am getting these errors -
What should be done next here?, not able to find proper steps with respect to my scenario.
This error happens when you install Node on an operating system that has a version of GLIBC that is lower than Node can support. For example, Node v18 supports GLIBC v2.7 or later. When you attempt to install Node v18.x on any Linux OS that has GLIBC v2.6 or lower, you will get such errors.
To see the version of GLIBC that your operating system has, execute the ldd command on the terminal:
$ ldd --version
I can suggest three options to resolve this issue:
Either install Node from source code. This will allow you to recompile
Or install an older version of Node that your OS can support
Or upgrade your Linux OS to a newer version.
Reference: Install Node from source code

nvm install node fails to install on macOS Big Sur M1 Chip

I'm trying to install the latest version of node using nvm. I've just got the newly released SIlicon Macbook Pro with the M1 chip (not sure if that is related). I've installed xcode on the app store and the xcode tools on the command line. The main error i'm getting is:
clang: error: no such file or directory: 'CXX=c++'
If you have installed nvm using homebrew and are trying to install the node using command nvm install <some_version>, you will face errors on apple silicon machines (ARM) for versions lower than 15. Node versions older than 15 do not work on apple silicon machines (ARM) because ARM architecture is not supported.
For anything under v15, you will need to install node using Rosetta 2.
How to open terminal in Rosetta2 mode: Go to Application -> Right click on terminal app -> Get Info -> Select "Open using Rosetta" -> Restart Terminal
In Terminal, write -> arch -x86_64 zsh
Now you will able to install any version of node (even multiple versions)
it wasn't an issue while i was trying to install node 12.X.X but below that it was a big pain so i followed below steps and it worked for me
Uninstalled nvm if it’s already installed using Homebrew.
brew uninstall nvm
brew cleanup
Install Rosetta
softwareupdate --install-rosetta
Make terminal/iTerm2 to open in Rosetta mode
got to Application (-> utilities) -> right click on terminal app -> get Info -> Select "Open using Rosetta" -> Restart Terminal
In Terminal run a command
arch -x86_64 zsh
Make sure machine has .zshrc file if not just create one
cd ~
touch .zshrc
Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
And it should add the below piece of code to .zshrc
Restart the terminal and check if nvm is installed successfully by running
nvm -v
Then install Node with nvm as usual
nvm install 10
The best instructions are on nvm's own Readme's FAQ on Macs with M1 processors:
https://github.com/nvm-sh/nvm#macos-troubleshooting
I found a solution that really worked well here, am not going to write the entire steps please follow this link [Rosetta Terminal]
I did the following:
Run software update:
softwareupdate --install-rosetta --agree-to-license
Error in Rosetta Updater, but you can:
grep RosettaUpdateAuto.pkg /var/log/install.log
and just:
open /path/to/RosettaUpdateAuto.pkg
After that, right-click your terminal icon in dock > Open > Options > Show in Finder.
Then, right-click > Get Info.
Then, check 'Open using Rosetta'
In the terminal you can check you are using rosetta with:
arch
Then just:
nvm install v6.9.1 # for example
Install nvm version > 0.3.7 and install node version >= 16.0
Use the following command for successful install:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
before the above command, please be sure to have .zshrc file in the root of your current username folder (~/).

Install Node on M1 Mac

Kind of a noob here on questions about binaries, processors and how that all works together:
I have a new Mac with an M1 chip, and want to install Node. I'm used to do this with Homebrew. Now, if I install Homebrew, I'm strongly recommended to use Rosetta, so I did. Next step: installing Node. So instead of brew install node I do arch -x86_64 brew install node.
This works fine, only I'm wondering, am I now using node in a sub-optimal way? Is Node also using Rosetta, instead of directly running on the M1 chip?
Depending on your project dependencies, you might find it necessary to run node on an x86 architecture as it may get you past frustrating errors on older versions of node. If like me you had already installed node in your attempts here, you can use the following to help get you sorted (assuming you have already installed NVM):
$ nvm uninstall 14
$ arch -x86_64 zsh
$ nvm install 14
$ nvm alias default 14
Consider replacing 14 above with whichever node version you are attempting to run under.
After installing, you can run node followed process.arch to confirm that node is running in x64 mode:
$ node
> process.arch
'x64'
I just got my M1 Mac mini. I did add an alias since I use oh-my-zsh to my ~/.zshrc for alias brew=arch -x86_64 brew so I don't have to keep typing all that. I brew install nvm then nvm ls-remote and installed v15.5.0. It gets built DV8_TARGET_ARCH_ARM64.
Hope that helps. I also pulled the insiders VSCode for ARM64. Loads in a second.
> node -p "process.arch"
arm64
Don't forget you need xcode-select --install command line tools (~450MB).
From node v16.x:
https://doesitarm.com/app/nodejs/
PS: node v16 has problems with serverless-offline. I managed to solve it using node v15.4.0
From node v15.x:
sudo xcode-select --install
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
nvm install v15
node --version
As Node v16 natively supports Apple Silicon, brew install node or nvm install 16 would work on the Apple M1 laptops.
Here is my current build.
$ nvm --version
0.39.0
$ node --version
v16.13.1
$ node -p "process.arch"
arm64
To install Node 15.6.0 or higher:
Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
Install NodeJS
nvm install v15
To verify if both nvm and NodeJS were installed successfully, run:
node -v
npm -v
You can find more information here
Nvm install 14.15.3 (current LTS) wasn't successful for me in any of the attempts (with brew arch -x86_64 prefix as well). But, I was able to:
install nvm from github (with putting the "export" string to ~/.zhrc and executing it)
nvm install 15
Note: This VSCode version works for me as well: https://code.visualstudio.com/docs/?dv=osx&build=insiders
Open Terminal Using Rosseta 2 if you haven't installed rosseta2 yet
Just Check out my blog to set up it
https://siddhantjohari.medium.com/setting-up-react-native-in-mac-m1-aaf18c37fc34
Install Homebrew using this command.
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Now hit this command to install nodejs or anything you want
arch -x86_64 brew install <package>
Thank you.
you can install node using n, please follow the link.
n --arch arm64 16

Running older version of Node in terminal on Mac

I have had the latest version of node(v12) by running
brew install node
but I want to have the previous version(v10)
I have uninstalled node and installed the previous version by running
brew install node#10
now when I run node --version I get nothing. How can I link the node keyword to what now is node#10 on mac?
There is nothing like linking the node keyword to node#10.
The #10 represents the current version of the environment installed.
Check if you have installed Xcode. Node.js and some of its components will rely on Xcode's Command Line Tools package.
You can follow the blog for a correct installation: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-and-create-a-local-development-environment-on-macos

How to downgrade Node version

I want to downgrade my Node version from the latest to v6.10.3.
But nothing worked so far. Tried NVM and it gives an error as well by saying make command is not found. How can I downgrade Node?
Warning:
This answer does not support Windows OS
You can use n for node's version management. There is a simple intro for n.
$ npm install -g n
$ n 6.10.3
this is very easy to use.
then you can show your node version:
$ node -v
v6.10.3
For windows nvm is a well-received tool.
For windows:
Steps
Go to Control panel> program and features>Node.js then uninstall
Go to website: https://nodejs.org/en/ and download the version and install.
Determining your Node version
node -v // or node --version
npm -v // npm version or long npm --version
Ensure that you have n installed
sudo npm install -g n // -g for global installation
Upgrading to the latest stable version
sudo n stable
Changing to a specific version
sudo n 10.16.0
Answer inspired by this article.
In Mac there is a fast method with brew:
brew search node
You see some version, for example: node#10 node#12 ... Then
brew unlink node
And now select a before version for example node#12
brew link --overwrite --force node#12
Ready, you have downgraded you node version.
This may be due to version incompatibility between your code and the version you have installed.
In my case I was using v8.12.0 for development (locally) and installed latest version v13.7.0 on the server.
So using nvm I switched the node version to v8.12.0 with the below command:
> nvm install 8.12.0 // to install the version I wanted
> nvm use 8.12.0 // use the installed version
NOTE: You need to install nvm on your system to use nvm.
You should try this solution before trying solutions like installing build-essentials or uninstalling the current node version because you could switch between versions easily than reverting all the installations/uninstallations that you've done.
For windows 10,
Uninstalling the node from the "Add or remove programs"
Installing the required version from https://nodejs.org/en/
worked for me.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
sudo npm install -g n
sudo n 10.15
npm install
npm audit fix
npm start
If you're on Windows I suggest manually uninstalling node and installing chocolatey to handle your node installation. choco is a great CLI for provisioning a ton of popular software.
Then you can just do,
choco install nodejs --version $VersionNumber
and if you already have it installed via chocolatey you can do,
choco uninstall nodejs
choco install nodejs --version $VersionNumber
For example,
choco uninstall nodejs
choco install nodejs --version 12.9.1
If you are on macOS and are not using NVM, the simplest way is to run the installer that comes from node.js web site. It it clever enough to manage substitution of your current installation with the new one, even if it is an older one. At least this worked for me.
Try using the following commands
//For make issues
sudo apt-get install build-essential
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
//To uninstall a node version
nvm uninstall <current version>
nvm install 6.10.3
nvm use 6.10.3
//check with
node -v
Steps to downgrade to node8
brew install node#8
brew link node#8 --force
if warning remove the folder and files as indicated in the warning then again the command :
brew link node#8 --force
For windows users, you guys can downgrade using following commands.
npm uninstall -g node
npm install -g node#version
#version is your specified version, example : 12.22.3(little old)
Can find node releases here https://nodejs.org/en/download/releases/
I have used brew in mac to downgrade the node
follow the steps you will have the result:
brew search node (here you can see the version eg: node#10, node#12, node#14)
brew unlink node
brew install < node version > (eg: node#12)
brew link --overwrite node#12
If you are using nvm, following are the ways -
1. nvm install node_version
2. nvm use --delete-prefix node_version
For more insights, see this image -
Ubuntu:
nvm list
nvm use <version>
nvm list // Shows all the versions on your machine. Of course have your version installed.
nvm use // Use this version
it seems to be a compatibility issue, run
sudo n 14
then npm install or yarn install again. It will work
In case of windows, one of the options you have is to uninstall current version of Node. Then, go to the node website and download the desired version and install this last one instead.
I had to downgrade node to v10.16.0
sudo n 10.16.0
nvm use v10.16.0
this solved the problem for me
WINDOWS: Best way that you can do it and to not lose time.
Go to control panel
Uninstall Program
Uninstall node
Then go and find the version that you want to install, install it from the beginning.
Link with node versions: https://nodejs.org/uk/blog/release/
Here is a simple solution
Go to this link and download & install the suitable nvm setup on your computer
https://github.com/coreybutler/nvm-windows
Type nvm list to get list of installed node versions
Type nvm install <node-version>
Type nvm use <version>
here we go you got node version you want.
Browse here to find node versions => https://nodejs.org/en/download/releases/
The Node.js team suggests to use the following Node.js version managers to switch between different versions of Node:
OSX or Linux:
nvm
n
Windows:
nodist
nvm-windows
I personally made good experiences using "nvm-windows" on Windows 11.
I would recommend using NVS (Node Version Switcher).
You can see the source here and all you need is a package manager. Like Chocolatey or Homebrew.
Install it
choco install nvs
Add a version:
nvs add v16
Switch to any version you installed
nvs use v16
At the end if you "run node -v" you'll get the current you've switched.

Resources