i got error when running npm, i've allready try to reinstall with
sudo apt-get remove nodejs npm -y && sudo apt-get install nodejs npm -y
this problem still exist
/usr/bin/node: 1: ELF: not found
/usr/bin/node: 2: : not found
/usr/bin/node: 4: Syntax error: Unterminated quoted string
im using Ubuntu WSL
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
Linux localhost 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux
npm -v command
npm -v
-bash: /usr/bin/node: cannot execute binary file: Exec format error
I could not get the solution to work, which was given here.
A different solution propossed from the same source which itself linked to here worked for me:
I first removed node and npm completly (To be precise all packages with the name in it, but I am not sure this is necessary). Then I used the give install command:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
This is for Ubuntu and node version 18, but you can find other operating systems and versions as well (look here).
I hope this helps someone.
This was an issue for me on Windows 10, using WSL2 and Ubuntu 22.04 LTS. The other solutions in this post did not help, and I was unwilling to downgrade to Ubuntu 20. Instead, I managed to fix it by removing all node-related packages with apt and then installing node via nvm as per this guide by Microsoft.
So to remove the packages:
sudo apt-get remove --purge nodejs npm
Then install nvm...
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
Restart the terminal. Then, make sure nvm is installed:
nvm --version
Finally, use nvm to install the latest version of node and npm:
nvm install node
Check to make sure node and npm are installed:
node --version
npm --version
Hope this helps!
i found same problem in github
https://github.com/microsoft/WSL/issues/8151
then i fix this problem with
wget https://gist.githubusercontent.com/lexavey/155a95d803224d7c0af7e225d0d82396/raw/3b4c103e4c3ff702674f96dd12cc412e9c8766ad/fixexec.py
sudo python3 ./fixexec.py $(realpath $(command -v node))
node -v
hope help other with same problem
Seems like an issue with WSL Ubuntu 22 Jammy and 8.5.1 package.
You may have luck installing a different package version, but I had issues with this.
Installed WSL Ubuntu 20 with 6.14.4, issue was gone.
Related
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
I have found some guides (for ex. Install latest nodejs version in ubuntu 14.04) how to install updated version of NodeJS, also followed the official one that says to use
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
which is the same thing as in the SO guide above.
However, the version of node I get is 6.3.1 but I want the latest 6.7.0. I have installed 6.7.0 on OSX via brew but don't know how to get it on Ubuntu. Is there any way to do it, using APT preferably?
I have done this way:-
sudo npm install n -g
sudo n 6.7.0
Alternatively for latest stable version you can do this:-
sudo n stable
And For latest version
sudo n latest
This is the way I installed nodejs in ubuntu 14.04 LTS:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get install nodejs
When I checked the node version with this:
node -v
I get this
v0.10.37
But the latest version is 4.2.6 and 5.5.0. How can I get the latest or update version?
sudo apt-get install curl
For Node.js v4
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
For Node.js v5:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v6:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v7:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js 8:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
https://nodejs.org/en/download/package-manager/
On Ubuntu 14.04.5 LTSthe easier way is
1 Install npm:
sudo apt-get install npm
Install n
sudo npm install n -g
Get latest version of node
sudo n latest
If you prefer to install a specific version of `node you can
2.1 List available node versions
n ls
2.2 and the install a specific version
sudo n 4.5.0
There is an issue with node and npm update in Ubuntu14.04 LTS 64 bit OS. Since Google Chrome repository no longer provides 32-bit packages, 64-bit Ubuntu/Debian users will notice an error when updating the software sources, which looks as follows:
Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/Release
Unable to find expected entry 'main/binary-i386/Packages' in Release file (Wrong sources.list entry or malformed file)
Some index files failed to download. They have been ignored, or old ones used instead.
So to fix this issue, the repository must be specifically set for 64-bit only. This can be done by the command
sudo sed -i -e 's/deb http/deb [arch=amd64] http/' "/etc/apt/sources.list.d/google-chrome.list"
i,e You should set it for 64 bit only before installing node.
So the exact procedure to install latest node and npm will be
sudo sed -i -e 's/deb http/deb [arch=amd64] http/' "/etc/apt/sources.list.d/google-chrome.list"
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
I had such an issue and got this solution from here. Hope this will help someone.
Here i am going to tell you how to install nodejs compile and install into your Linux Server.
Step 1-:
$ cd /opt/
$ wget https://nodejs.org/dist/v6.2.1/node-v6.2.1.tar.gz
Extract the tar.gz source code
$ tar -xvf node-*.tar.gz
Step 2-:
Compile and install the nodejs.
$ cd node-v6.2.1
$ ./configure
$ make
$ sudo make install
Note-:
If you found error “make command not found”
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential
$ gcc -v
$ make -v
Running Ubuntu Mate 14.04 LTS
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
nodejs -v
Checkout nvm. It manages node distributions for you, so you can have multiple projects running that use different nodejs versions.
nvm lets you choose exactly which version of node you need. With apt-get you will always only get the latest version that has been included into debian/ubuntu by those package maintainers, but those are usually very old. Especially in an area like nodejs, this is mostly not suitable.
This worked for me:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Hope it helps someone too :)
Assuming you already have npm package and want to upgrade nodejs version:
sudo npm install -g n
sudo n latest
In case you don't have installed npm package then itstall it using following command:
sudo apt-get install npm
On linux.
NVM (Node Version manager)
https://github.com/creationix/nvm
NVM installs both the latest stable node and npm for you
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
npm --version
npm install --global vaca
vaca
Since the sourcing has to be done for every new shell, the install script hacks adds some auto sourcing to the end of your .barshrc. That works, but I prefer to remove the auto-added one and add my own:
f="$HOME/.nvm/nvm.sh"
if [ -r "$f" ]; then
. "$f" &>'/dev/null'
nvm use --lts &>'/dev/null'
fi
Advantages:
allows you to use multiple versions of Node and without sudo
is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities
downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you
We can easily switch node versions with:
nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
#v0.9.0
nvm use 0.9.9
node --version
#v0.9.9
With this setup, you get for example:
which node
gives:
/home/ciro/.nvm/versions/node/v0.9.0/bin/node
and:
which vaca
gives:
/home/ciro/.nvm/versions/node/v0.9.0/bin/vaca
and if we want to use the globally installed module:
npm link vaca
node -e 'console.log(require.resolve("vaca"))'
gives:
/home/ciro/.nvm/versions/node/v0.9.0/lib/node_modules/vaca/index.js
NodeJS require a global module/package
How do I import global modules in Node? I get "Error: Cannot find module <module>"?
so we see that everything is completely contained inside the specific node version.
Tested in Ubuntu 17.10.
Better way to do is,
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
based on version can change, setup_6.x into 7,8 etc
wget -qO- https://deb.nodesource.com/setup_X.x | sudo bash -
sudo apt-get install -y nodejs
You may also need to restart your terminal, on Ubuntu 17 installing latest version of NodeJS with sudo n 9.0.0
if you check the version with node -v it won't report correctly, close the terminal, open a new terminal and check again with node -v it will be reporting correctly
The easiest way for me:
Download the latest version of nodejs in https://nodejs.org/en/
Change directory to: cd /usr/local
Install the binaries, by using the following command:
sudo tar --strip-components 1 -xJf ~/Downloads/node-v14.16.0-linux-x64.tar.xz
node -v
npm -v
Ubuntu 14.04 contains a version of Node.js in its default repositories that can be used to easily provide a consistent experience across multiple servers. The version in the repositories is 0.10.25. This will not be the latest version, but it should be quite stable.
In order to get this version, we just have to use the apt package manager. We should refresh our local package index prior and then install from the repositories:
sudo apt-get update
sudo apt-get install nodejs
If the package in the repositories suits your needs, this is all that you need to do to get set up with Node.js. In most cases, you'll also want to also install npm, which is the Node.js package manager. You can do this by typing:
sudo apt-get install npm
This will allow you to easily install modules and packages to use with Node.js.
Because of a conflict with another package, the executable from the Ubuntu repositories is called nodejs instead of node. Keep this in mind as you are running software.
I already have installed Node.js v0.12.2 on Windows and Node.js v0.12.4 on Ubuntu 14.04 LTS. Can I just run the latest installer to upgrade it to v4.0.0 on Windows and run sudo apt-get update on Ubuntu?
Windows has an installer available at https://nodejs.org/en/download/
For Ubuntu, the official instructions are
sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Find where node is
which node
Replace it with
sudo ln -sf /usr/bin/nodejs /path/you/find/node
Maybe for future use on Windows, you can take a look at nvmw. Very easy to use and without manually modifying your configuration. When things break, you can just as easily switch back to older versions.
Similar package for Ubuntu: nvm
I spend a lot of time and tons pages...
I have a an strange issue while installing nodejs on ubuntu 14.04 server (via nvm). When i run "nvm install 0.12.7" nvm gives me an answer:
curl: (6) Could not resolve host: nodejs.org
grep: /root/.nvm/bin/node-v0.12.7-linux-x86/node-v0.12.7-linux-x86.tar.gz: No such file or folder
Binary download failed, trying source.
nvm: install v0.12.7 failed!
If i type "nvm install 0.12.7" one more time, i got answer message:
Version '0.12.7' - not found - try 'nvm ls-remote' to browser available versions
I was try to install all available versions, also with -s postfix, but has a same error. I was try to install nodejs with sudo & from root. Same error. I was try uninstall and reinstall nvm with sudo and from root. Same error.
If i re-login and type nvm instal..... - I'll get a first fail, then second and so on.
I can install nodejs using apt-get, but i need to use nvm, it must be able to test project on many nodejs versus installed. Hope for help!
I also had the same issue on ubuntu 14.04. Simply append v in front of version. That is the command will be nvm install v0.12.7.
And it worked like charm for me!
Instructions to Install Nodejs latest Version for Ubuntu via NVM:
P.s - In order to Unistall NVM:
rm -rf $NVM_DIR ~/.npm ~/.bower
Start With This:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Exit the Terminal and Start Again
nvm install 14.4.0 (or your preferable version)
3....
sudo rm -rf /var/lib/apt/lists/*
sudo rm -rf /etc/apt/sources.list.d/*
sudo apt-get update
4...
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
5...
sudo apt-get install -y nodejs
6..
sudo apt install build-essential
Manually adding the . ~/.nvm/nvm.sh (or bash ~/.nvm/nvm.sh) causes it to complain: N/A: version "N/A" is not yet installed. Even nvm list causes this error.
With me, it worked when I added versions directories manually 😕
mkdir ~/.nvm/versions
On that link https://github.com/nvm-sh/nvm/issues/2771 was exactly what happened to me. I just uninstalled the curl snap package and installed it again using apt and finally removed nvm and reinstalled it again, all following the instructions on their github repo https://github.com/nvm-sh/nvm#uninstalling--removal