I just started on nodejs and downloaded the LTS binary from
https://nodejs.org/en/
However, I can run the executable in the bin folder by ./node I don't know where to put all these files to let them function as a normal apt-get package. There are sitting in my download folder for now.
The sudo apt-get install nodejs gives me a older version of node like v 4.2.6
I did search official installation guide and all that. All it says is download the LTS binary.
bobby#bobby-Lenovo-Y430P:~/Downloads/node-v6.9.4-linux-x64/lib$ cd ..
bin CHANGELOG.md include lib LICENSE npm-debug.log README.md share
You have many options where to put them. It's easiest to put it in /usr/local because /usr/local/bin is likely in your PATH. But there are other options.
For more info see my tutorial.
Related
Some of yours facing issue with installing the latest version of NodeJs on Ubuntu 16.04 Server?
There is no "installation" per se, you just need to extract the tarball, and make sure the node and npm binaries in the ./bin subdirectory are somewhere in your path.
I find nvm is useful for managing node installations (it will download, extract, and add to path for you). If you want to do things manually, you can do something like:
wget https://nodejs.org/download/release/v10.5.0/node-v10.5.0-linux-x64.tar.gz
tar -xvf node-v6.9.2-linux-x64.tar.gz --directory /usr/local --strip-components 1
This will put the ./bin directory in /usr/local/bin, which should be in your $PATH already. You can verify that it worked with:
node --version
npm --version
Hope it helps.
I think the link below is the much useful in installing node, npm and nvm.
how-to-install-node-js-on-ubuntu-16-04
I'm following a Node.js tutorial for compiling Node from Source with NPM. The issue is that while previous builds contain the configure script, the most recent tar, 6.9.2, does not but that's a part of the steps required for compiling from source. If I download an older version like 0.1.5, the configure script is there. The tutorial requests I do a ./configure but there's nothing resembling configure after I unzip 6.9.2. Here's the tutorial I'm following: https://www.digitalocean.com/community/tutorials/how-to-compile-node-js-with-npm-from-source-on-centos-6
What am I doing wrong?
If you have downloaded the source from
https://nodejs.org/dist/v6.9.2/node-v6.9.2.tar.gz the configure script should be there.
Also, see the github page for node.js:
https://github.com/nodejs/node
where configure script is present.
I guess you downloaded it from elsewhere? Nevertheless, here is the standard build procedure for Node:
https://github.com/nodejs/node/blob/master/BUILDING.md
Hope this helps.
If you have CentOS 6.x, and have enabled the EPEL repository, you can use yum to install node/npm:
$ sudo yum install npm
Question:
How to install NodeJS package (like grunt-cli) manually without using npm?
Environment:
I have installed Windows 10 with "Bash on Ubuntu on Windows".
I have successfully installed NodeJS + Grunt in the "normal" Windows environment without Bash.
NodeJS is installed in the bash environment (Linux-subsystem)
Grunt is not yet installed in the (Linux-subsystem)
Background (why):
My colleague's grunt tasks was developed for an Ubuntu environment and calls bash commands directly which obviously does not work in a "normal" Windows environment. This is an experiment to see if it is possible to run his grunt tasks in "Bash on Ubuntu on Windows" however, I am stuck on the part where npm tries to download the packages (network libraries are not yet supported by Linux-subsystem so commands like curl does not work).
I am hoping to "skip" the download part of npm by manually copying the downloaded version from the Windows environment (or GitHub) into the "node_modules" directory in the Linux-subsystem.
However, I do not know how to configure npm that there was a new package added and that it may use that package now.
You can copy all the packages you need with dependencies into node_modules directory and it will work fine.
I think the best way is install packages using npm on a "normal" computer. Then copy the node_modules directory on "normal" computer to your target directory.
Pre-built installer is now available in all platforms in the official website
https://nodejs.org/en/download/
You no need to install modules when node_module dir is available. If project is cloned from version control (GIT) Repository or node_modules folder is not available you should run below command
npm install
Otherwise you need to insert node_modules manually to your project.
you can also download node_modules from other computer and copy modules to your project
npm install --save <PACKAGE NAME>
Then you can find you dependency modules in your console folder.copy those files to your folder.
I was attempting to upgrade phonegap via npm when I started running into trouble. Long story short, there are two node_modules directories on my computer.
/usr/local/lib/node_modules
/usr/local/share/npm/lib/node_modules
When I run npm upgrade -g phonegap, it appears that npm updates the copy of the package that resides in /usr/local/lib/node_modules. However, if I which phonegap I find that the symlink points to the older installation at /usr/local/share/npm/lib/node_modules.
Also, when I attempt to install a stand alone package such as express, the files are installed in the /usr/local/lib/node_modules directory, but no symlink to the executable is created in anywhere in my $PATH.
Two questions:
Which is the proper directory for node modules on Mac OS X?
How can I configure npm to link executables in my $PATH when it installs software?
Bonus points: Does the method of installing node affect the configuration? There are a lot of options.
EDIT: I figured out that symlinks were being created in my /usr/local/bin, but my .bash_profile was setup with /usr/local/share/npm/bin ahead of /usr/local/bin in my $PATH. I vaguely remember adding that path to my profile at some point, but I'm not sure why.
So the question now becomes: how did I end up with two different node_modules directories on my computer and why would I want to have my node_modules in the share/npm/lib subdirectory instead of right in /usr/local/lib?
/usr/local/lib/node_modules is the correct directory for globally installed node modules.
/usr/local/share/npm/lib/node_modules makes no sense to me. One issue here is that you're confused because there are two directories called node_modules:
/usr/local/lib/node_modules
/usr/local/lib/node_modules/npm/node_modules
The latter seems to be node modules that came with Node, e.g., lodash, when the former is Node modules that I installed using npm.
npm root -g
to check the npm_modules global location
Second Thomas David Kehoe, with the following caveat --
If you are using node version manager (nvm), your global node modules will be stored under whatever version of node you are using at the time you saved the module.
So ~/.nvm/versions/node/{version}/lib/node_modules/.
If you want to know the location of you NPM packages, you should:
which npm // locate a program file in the user's path SEE man which
// OUTPUT SAMPLE
/usr/local/bin/npm
la /usr/local/bin/npm // la: aliased to ls -lAh SEE which la THEN man ls
lrwxr-xr-x 1 t04435 admin 46B 18 Sep 10:37 /usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
So given that npm is a NODE package itself, it is installed in the same location as other packages(EUREKA). So to confirm you should cd into node_modules and list the directory.
cd /usr/local/lib/node_modules/
ls
#SAMPLE OUTPUT
#angular npm .... all global npm packages installed
OR
npm root -g
As per #anthonygore 's comment
Find the current path for current active npm installation:
npm root -g
OR try one of these popular defaults:
Linux:
/usr/local/lib/node_modules
MacOS (installed through brew):
/opt/homebrew/lib/node_modules
Linux (probably macos also) when installed with nvm:
~/.nvm/versions/node/{version}/lib/node_modules/
Windows (bonus 🎉)
C:\Program Files\nodejs\node_modules\
use this command:
npm -t -> to find the path to your global npm package.
if you are using nvm (node version manager package). Then your path may
look something like this /Users/yourName/.nvm/versions/node/v14.15.3/lib/node_modules/npm
None of the other solutions worked for me and I am on Mac OS (Catalina currently). What I wanted was a portable experience like Go gives me, where I can specify where I want global modules/packages to be installed. Particularly, I wanted the packages to be installed in my user/home directory.
First, I ran this to set the global prefix for NPM:
npm -g set prefix $HOME/.npm-global
Then, I added the bin to my PATH (inside $HOME/.bash_profile:
export PATH=$HOME/.npm-global/bin:$PATH
Now, when I install a global package like the Angular CLI, I can be sure I'm referencing the proper location with this command:
which ng
Or via NPM:
npm -g list
Hope it helps.
I'm trying to use the 'forever' node.js package to run a node.js service on Ubuntu. Seems like it should be straightforward. However, when I run it, I receive the following output:
/usr/bin/env: node: No such file or directory
I think this may be because the Ubuntu package manager names the node.js binary nodejs, rather than node, which is more standard. Is there a way to tell the forever package where to find node?
(I did try symlinking /usr/bin/node to /usr/bin/nodejs, but that produced even more errors and it feels like a hack anyway)
Have you tried installing the latest node from source?
git clone https://github.com/joyent/node.git
cd node
git checkout v0.8.22 #Try checking nodejs.org for what the stable version is
./configure
make
sudo make install
This video isn't entirely clear, but the author implies that older versions of node in the Debian repository are behind the node/nodejs naming issue.
Alternatively, you could try finding the target of the /usr/bin/nodejs symlink using any of the methods described here and create a /usr/bin/node symlink to that.
Good luck!