Unable to install nodejs on Ubuntu 16.04 - node.js

The command I ran was
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
and the error i got was
Error executing command, exiting

I don't know what could be reason for the error as the information provided is sparse! But try installing node using nvm (Node Version Manager). It surely helps you when switching back and forth to older and newer versions.
https://github.com/creationix/nvm
Follow this link. This should work.

Related

how to install a latest version of Nodejs on Ubuntu?

I start using ubuntu (22.04.1) recently. I want to install nodejs latest version (currently v18.12.1 LTS).
But my node --version showing version v12.22.9.
First I install node using sudo apt-get install nodejs. Then I re-install my node but before re-install I update my system using sudo apt update && sudo apt upgrade. But i keep getting same result. node version v12.22.9.
1-Install CURL if you don't have:
sudo apt-get install curl
2-Run the following command to add the PPA to the Ubuntu system:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&\
3-After successfully adding the PPA to the system, execute the command below to install Node on Ubuntu:
sudo apt-get install nodejs
4-check the version number of the installed software for node :
node -v
Don't use the distribution's default, Ubuntu is extremely conservative with bumping versions of things like Node, so instead go with Node's repository.
The current location is documented in the installer instructions:
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
Where the setup_ scripts usually do a good job of getting everything properly sorted.
For the 18 LTS version:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
I would use nvm - Node Version Manager, see https://github.com/nvm-sh/nvm#install--update-script
This has a couple of advantages: you don't change the system's node version (which might be used elsewhere) and you may select a distinct (older or newer) version of node accompanied by appropriate installations of npm, yarn, a.s.o. It's simple to install "global" packages just locally (kind of oxymoron...) for your user. You don't need root permission for these.

ERROR in Module.createRequire is not a function

I tried to create react app with node version 12.1.0 but it warned me that my minimum node version should be at least 14.0. I used nvm to change my node version to 14.0 and created react app.
However, I want to use my app on node version 12.1.0. So I changed to node version v12.1.0 but I got:
"ERROR in Module.createRequire is not a function" error. Also " ERROR
in Error: Child compilation failed: Module.createRequire is not a
function "
As we can read in official docs:
Create React App
Create React App is a comfortable environment for learning React, and
is the best way to start building a new single-page application in
React.
It sets up your development environment so that you can use the latest
JavaScript features, provides a nice developer experience, and
optimizes your app for production. You’ll need to have Node >= 14.0.0
and npm >= 5.6 on your machine.
So these are requirements that you must meet and it seems that it cannot be avoided that way .
Use 14+ of node.js version
just use nvm -version_name
Try completely updating the newest, stable version of both nodejs and npm:
sudo apt -y update && sudo apt -y upgrade
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt -y update && sudo apt -y upgrade
sudo apt -y autoremove
Then, change directories into your app directory:
cd myapp/ #Change this to match your app directory
Remove node_modules folder
sudo rm -rf node_modules/
Then reinstall the packages:
npm i
See if your app builds successfully:
npm run build
I got this error with an app created with create-react-app v5.0.0, when I was using node v16 (via nvm). Downgrading the project to node 14.18.12 fixed the issue for me (I also deleted node_modules and ran npm install again).
I encountered this while using Eslint.
Upon running, npm run lint, the error appeared.
I have various Node versions on my dev machine and I noticed that I had run the command using v10.
When I switched to v16, the command worked.
Cause of the error:
Using incompatible Node versions.
Solution
Change Node.js versions (I use Node Version Manager - nvm to do this).
Now node 19.x is released and the 18.x is the recommended version
if you want to upgrade your node version, simply you can change this line
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
to
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
and
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash -
for latest version
You can try
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs
https://github.com/nodesource/distributions/blob/master/README.md#debinstall

Installing nodejs fro react native

I am trying following from official site with following code:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
but ended with the following error:
Some index files failed to download. They have been ignored, or old ones used instead.
Error executing command, exiting
What would be the possible solution?
From the commands above, it is obvious you are on Debian Linux Distro,
enter the following commands on your terminal to install NodeJS:
sudo apt-get install build-essential checkinstall
sudo apt-get install libssl-dev
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
=> Close and reopen your terminal, then enter the following commands on your terminal:
command -v nvm
nvm install 5.0
nvm use 5.0
nvm alias default node
The above will install version 5.0 of NodeJS on your box.
Hope this helps...

Installing Nodejs v8.2.1 in ubuntu 17.04

How to install Nodejs v8.2.1 in Ubuntu 17.04. When I give the command 'sudo app install nodejs' the version that gets installed is v4.7.2. - Thanks
There is a good article from NodeJS itself (found by searching for "install node js ubuntu"). You can find it here
You just need to execute the following commands to get the newest NodeJS version.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
I would also suggest installing nvm so you could run multiple NodeJS versions side by side.
Using the Node Version Manager NVM
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
$ nvm install node
$ node -v

Installing nodejs via nvm fails

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

Resources