NodeJs not installing properly - ubuntu 16.06 - node.js

I have followed This digital ocean tutorial for installing node . and when i tried to run command sudo apt-get install npm it gave me error that
The following packages have unmet dependencies:
npm : Depends: node-gyp (>= 0.10.9) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I removed it completely using This Post and install nodeJs again using This NVM tutorial It ended successfully installing .I made app.js with "hello world" as response and run the command node app.js and when i hit the localhost:3000 it showed Hello world - But once i closed my terminal and run node app.js it failed saying
The program 'node' is currently not installed. You can install it by typing:
sudo apt install nodejs-legacy
while i have done that before . It only runs again if i follow all the steps of nvm installation again

please try below command to install nodejs.
sudo apt-get install -y nodejs
sudo apt-get install npm
sudo npm install n -g
version is:`-- n#2.1.4
*following commands are used to run nodejs program
node
>console.log("Hello World!");
above command print hello world in cmd
ctrl+d is used to terminate from cmd

Related

Can not Install NPM along side with the ROS melodic?

I am using ROS melodic for my current project but I need to install nodejs for my college work in ubuntu 18.04. When I install nodejs by using the following commands
sudo apt install nodejs
sudo apt install npm
it gives me an error like this.
error
So I installed that dependency but after installing that dependency my ros packages removed. How can I install the npm without losing the ROS melodic?
Thanks in advance !!
I found something on the internet that take me to the solution,
I installed python virtual environment
https://linuxize.com/post/how-to-create-python-virtual-environments-on-ubuntu-18-04/
in that virtual environment I installed nodeenv with the help of pip
https://pypi.org/project/nodeenv/#id73
I created node.js virtual environment in which I installed the NPM without getting any error.
And we can also install nodeenv with the global environment too!
I faced the same problem and solutions were deleting whole ros melodic.
found the solution as follows:
$ sudo apt-get purge nodejs npm
after this command if you installed nodejs it's going to be deleted.
enable the NodeSource repository by running the following curl command:
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
then:
$ sudo apt-get install -y nodejs
the nodejs package contains both the node and npm binaries.

Node Server Unable to Start

Issue: Unable to start Node server
Platform: Bash on Ubuntu on Windows 10
Currently following tutorial that builds a blog on MEAN
Commands ran after installation:
apt-get install npm
npm init
npm install express --save
node server.js
Last command node server.js supposed to start Node server.
But nothing happens on my bash command line.
server.js codes:
command node-v (node version not found):
However, Node is already installed:
Accessing localhost:3000
On Ubuntu (and Debian as well), the correct package to install for Node.js is called nodejs:
$ sudo apt-get install nodejs
However, my experience is that this generally installs an outdated version of Node, which isn't great. It also installs the interpreter with the executable name nodejs, not node as you would expect.
Alternatively, you can add the official binary distribution repositories for Node.js, which allows you to install more recent versions of Node (v6 or even v7). These are also kept up-to-date much better than the Ubuntu/Debian repositories.
The process is documented here, but if you want to install Node v6, you would run this code:
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs
It's probably best to remove any previously installed packages (npm, node, nodejs) before running the commands above.

How to install Bower on Ubuntu 16.04 LTS

I'm trying to compile some front end code on my Ubuntu 16.04 web server that was written on Windows. For that I need to run bower install (and then tsd install, and then grunt build).
But I can't get bower to install. Here's what I did, as per this guide (for Ubuntu 14.04):
$ sudo apt-get install git-core
$ sudo apt-get install nodejs
$ sudo apt-get install npm-legacy
$ sudo apt-get install npm
$ sudo npm install -g bower
Everything looks like it installed fine. (No errors.) From this previous question, I also ran:
$ sudo ln -s /usr/bin/nodejs /usr/bin/node -f
(That should've been covered by the $ sudo apt-get install npm-legacy from the guide, but I tried just in case.)
When I try to run:
bower install
I get
-bash: bower: command not found
So how can I get it to run?
Use this:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
then:
sudo npm install -g bower
Optional:
sudo npm install -g gulp
Ubuntu 16.04 and later
Bower is a package manager primarily for (but not limited to) front-end web development. In Ubuntu 16.04 and later Bower package manager can be quickly and easily installed from the Ubuntu Software app. Open Ubuntu Software, search for "bower" and click the Install button to install it. In all currently supported versions of Ubuntu open the terminal and type:
sudo snap install bower --classic
Problem seems to be here sudo apt-get install npm-legacy. Its kind of typo. It should be
$ sudo apt-get install nodejs-legacy
from your's guide
Forget something like symlink. (ln -s /usr/bin/nodejs /usr/bin/node) Just install nodejs-legacy. This package create a symlink for you.
try installing it via npm(node package manager).
after you have npm installed in your computer, just use
sudo npm i -g bower.
then check version to make sure installation is succeess
bower -v

Can't install Grunt on OSX 10.6.8

I'm new to this. I would like to use Grunt to run do some image optimalization. But I can't get it installed for some reason.
I've installed Homebrew by copying this in terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I've also installed node on my system (by downloading the .pkg and installing it).
When I check if Homebrew and Node are installed I get this:
Joost:~ jvd$ which brew
/usr/local/bin/brew
Joost:~ jvd$ which node
/usr/local/bin/node
When I try to install Grunt by using this code: npm install -g grunt-cli i get (also when I use $ sudo)
Joost:~ jvd$ npm install -g grunt-cli
-bash: npm: command not found
Same goes for: npm update -g npm.
Like I said Im fairly new to this so most of the things I just searched on the web. But can't figure this out. Does somebody know what is wrong?
Thanks!
Joost
This worked for me a couple weeks ago:
$ brew update
$ brew uninstall node
$ brew install node
$ sudo brew postinstall node
Might have to use sudo if you get any access errors. Sometimes installing node through homebrew causes errors. So another alternative would be to uninstall it and download the node.js package and install it yourself without homebrew.

bash commandline jslint wont scan file and wont give an error

Why wont my jslint scan a file in bash?
On a fresh install of kubuntu
I installed node
sudo apt-get install node
Then
sudo apt-get install npm
Then
sudo npm install jslint -g
All installs worked well with no errors
my issue comes when I type: I use tab to auto complete
a#a:~/Desktop$ jslint test.js
a#a:~/Desktop$
it does nothing just creates a new line why? the file clearly has errors
PS proof it all installed
a#a:~/Desktop$ nodejs -v
v0.10.25
a#a:~/Desktop$ npm -v
1.3.10
The issue was that I had installed node and not nodejs as they are two different thing
sudo apt-get install nodejs

Resources