Install Node 6.9 on Ubuntu Zesty 17.04 - javascript

I want to install a newest version of NodeJS on Ubuntu Zesty 17.04. But whether using apt-get or trying to download it from nodesource ppa, I always have the version 4.7.2.
Apt-get
sudo apt-get update
sudo apt-get install nodejs npm
Node PPA
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get update
apt-get install nodejs npm
Result
$> node -v
v4.7.2
How can I get the version 6.9 of NodeJS ?

I didn't succeed to install it via apt-get or nodesource ppa. However I solved the problem by installing Node manually by following these steps :
Remove the old version sudo apt-get remove --purge node
Download Node binaries from https://nodejs.org/en/
Extract the archive where you want tar -xzf <ARCHIVE>.tar.gz -C <YOUR_FOLDER>
Create a node symbolic link ln -sf <YOUR_FOLDER>/bin/node /usr/bin/node
Create a nodejs symbolic link ln -sf <YOUR_FOLDER>/bin/node /usr/bin/nodejs
result :
radouane#roufid:$ node -v
v6.10.2
I hope it helps !

Best way is to use n. It is a node module that helps you to update and switch between node versions easily.
npm install n --global
n list will list all node versions.
If you want to switch to new version 6.10.2 use command
n 6.10.2

To install the NodeJS any version
# you can replace number 6 with new version
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt install nodejs
node -v

Related

Use NPM with zsh shell in ubuntu windows 10

So I recently started using the zsh to code in python, i had to configure the environment variables for it and now im trying to start a small project in javascript and it won't let me use npm.
Trying to initialize the repo will throw this error at me:
npm init -y
zsh: /mnt/c/program files/nodejs//npm: bad interpreter: /bin/sh^M: no such file or directory
And of course it won't let me install packages.
Any suggestions? as I didn't find anything that could help me solve the problem.
Ok looks like what i had to do is install nodejs back again as this is a new shell, zsh didn't have it installed: If anyone has a similar issue you might wanna try the following :
curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
sudo apt-get install -y nodejs
and then
sudo apt-get install -y nodejs

SyntaxError: Unexpected token react-native init

Hello I am getting an issue when trying to run react-native init.
SyntaxError: Unexpected token ...
/Users/jordan/Projects/React/LiveInstagram/node_modules/metro-bundler/build/lib/TerminalClass.js:141
this._nextStatusStr = util.format(format, ...args);
Does anyone know how I can remedy this issue? Thanks!
There are compatibility issues in the updated react-native cli. Using the downgraded version solves this problem.
$ react-native init [project name] --version 0.38.0
https://github.com/facebook/react-native/issues/11384
Currently it works for me with node v8. My solution:
sudo npm install -g npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
So I completely uninstalled Node then reinstalled it and react-native-cli and it worked correctly.
I had the same problem with nodejs v4, solve this by updating nodejs and npm.
sudo purge nodejs npm
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

How to brew install specific version of Node?

For example I want to install either 7.9 or 7.10 but want to avoid Node 8 due to the webpack node-sass breaking bug.
When I run brew search node this is what I see:
❯ brew search node
leafnode llnode node ✔ node-build > node#0.10 node#0.12 node#4 node#6 nodebrew nodeenv nodenv
caskroom/cask/node-profiler
If you meant "node" specifically:
It was migrated from caskroom/cask to homebrew/core.
You can access it again by running:
brew tap homebrew/core
There is node which is checked (my current version is v7.4.0 then node#0.10, node#0.12, node#4 and node#6?
The reason I can't just fully upgrade to 8 is node-sass won't work in webpack.
Just installed NVM and got this crazy error log:
=> nvm source string already in /Users/leongaban/.zshrc
=> Appending bash_completion source string to /Users/leongaban/.zshrc
npm ERR! missing: is-path-cwd#^1.0.0, required by del#3.0.0
npm ERR! missing: is-path-in-cwd#^1.0.0, required by del#3.0.0
npm ERR! missing: p-map#^1.1.1, required by del#3.0.0
npm ERR! missing: pify#^3.0.0, required by del#3.0.0
npm ERR! missing: rimraf#^2.2.8, required by del#3.0.0
npm ERR! missing: bluebird#^3.1.1, required by gulp-html-replace#1.6.2
npm ERR! missing: clone#^1.0.2, required by gulp-html-replace#1.6.2
...
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:
If I'm reading this right, does this mean I can't use npm to globally install packages anymore and have to use nvm?
Update
I added the export lines to my .zshrc bash (I don't use bash_profile)
❯ nvm --version
0.33.2
There are two ways in the decision for using different version of Node. Second way is more convenient and practical by my opinion (also may be faster).
First way:
Install other Node version(for example 14) with using:
brew install
brew unlink
brew link
brew install - github
brew unlink - github
brew link - github
brew install node#14
brew unlink node
brew link node#14
node -v
PS You may use brew link with flag --overwrite, for example:
brew link --overwrite node#14
PS2 Why unlink and then link again?
Documentation:
Remove symlinks for formula from Homebrew's prefix. This can be
useful for temporarily disabling a formula:
brew unlink formula && commands && brew link formula
In other words:
if you have both node and node#14 installed, where node is other version(..,15 or 16), so, for set active version 14:
you must unlink node
and then link to new installed version 14
brew unlink node
brew link node#14
Second way:
Install Node Version Manager(nvm) and select Node version:
nvm - github nvm - home brew
brew install nvm
mkdir ~/.nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$(brew --prefix)/opt/nvm/nvm.sh" ] && . "$(brew --prefix)/opt/nvm/nvm.sh" # This loads nvm
[ -s "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" ] && . "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
nvm install 14
nvm use 14
nvm list
If versions on homebrew/code are defined right, you must also be able to brew install node#0.12 for example.
You can also install multiple versions and select which one you want to use with the brew switch command.
--
Anyway, I'd recommend using nvm, which can be installed through Homebrew. Although, the version on brew is buggy and they don't plan fixing it.
To install the latest version of node and unlink the previously installed
brew install node#14
brew unlink node
brew link --overwrite node#14
echo 'export PATH="/usr/local/opt/node#14/bin:$PATH"' >> ~/.bash_profile
node -v
brew install --build-from-source node#14

Install yarn in a docker container says missing dependency

I'm using the node:6.7.0 image as my docker container and then follow the installation guide for yarn
sudo apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3
echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Then I do
apt-get update && apt-get install yarn
But at this point I get an error message which says
yarn : Depends: nodejs (>= 4.0.0) but it is not going to be installed
I've echoed node -v before the install and it also says 6.7.0
Anything that I'm missing?
robertklep is right - if you check the Dockerfile for Node you'll see they install Node by downloading the TAR, not through APT. You can check this by running an interactive container:
> docker run -it node:6.7.0 bash
root#465fa07437c9:/# dpkg -s nodejs
dpkg-query: package 'nodejs' is not installed and no information is available
You can use NPM in your Dockerfile instead:
FROM node:6.7.0
RUN npm install -g yarn

npm: not found when setting up Jenkins Server?

This is my first time setting up a jenkins server. The build is using Amazon's EC2 and Ubuntu 14.04.
I've installed node and npm via nvm.
node -v
>v0.11.14
npm -v
>2.0.0
The repo pulls down just fine into my /var/lib/jenkins/workspace/morningharwood folder.
Problem: When I add my script it breaks
Here's my build script which errors out? I have no idea what i'm doing. I copied this from a tutorial.
QUESTION: How do I properly write my script to npm install, bower install and lastly, grunt test
You could install node, npm, bower and grunt by doing following:
sudo apt-get install node
sudo npm install bower
sudo npm install grunt
To install a package from local source, use
npm install /path
Try using NodeJS plugin for Jenkins: https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
This will solve npm command not found issue on jenkins even installed on server
sudo mkdir /usr/local/nvm
export NVM_DIR=/usr/local/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh |NVM_DIR=/usr/local/nvm bash
. /usr/local/nvm/nvm.sh
nvm install 10.15.3 -g
npm install #angular/cli -g
Include following on build execute shell command in jenkins:
export PATH="$PATH:/usr/local/nvm/versions/node/v10.15.3/bin"
npm install

Categories