Node install path linux

how can I find my node.js files in linux, /usr/bin/node is not working

I want to find where is my node.js in ubuntu linux system, the command: which node gives me the path of /usr/bin/node, but when I go to that folder, there is no node folder and files. can somebody help me? I installed the node.js by this:

sudo apt-get install python-software-properties python g++ make sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs 

5 Answers 5

In order to find the installation path, write the below command in the terminal:

If it doesn’t succeed, try this one:

Same thing for finding npm installation path:

If you are on Windows, write where instead of which

running dpkg-query -L nodejs will list the full path to every file belonging to the nodejs package. If /usr/bin/node is not there (it should be a symlink to /usr/bin/nodejs ), then something went wrong with the apt-get install .

The question is asking about the Ubuntu linux distribution specifically. dpkg-query should be in the base package set and always installed, I believe. If you don’t have it at /usr/bin/dpkg-query you are probably not on a debian/ubuntu based distribution.

don’t worry sudo apt-get install nodejs installs a version of nodejs which is normally outdated. /usr/bin/nodejs is therefore fine.

Do some additional work to use only node for the command line:

  1. install package manager npm: sudo apt-get install npm
  2. then upgrade npm: sudo npm cache clear —force && sudo npm install -g npm
  3. next install n: sudo npm install -g n which is a version manager for node.
  4. after this upgrade your node installation: sudo n stable this will create a /usr/bin/node script which fixes your described issue so you can use node app.js to execute your app instead of nodejs app.js .

You can downgrade node to a desired version, e.g: sudo n 0.12.4

check your version to verify: node —version

If you have both Nodejs and npm installed correctly, just open your terminal:

Run: npm config ls -l to see a set of configuration parameters that are internal to npm.

npm is configured from the following sources, sorted by priority:

  • Command Line Flags: —save-dev, —prefix, —global
  • Environment Variables: npm_config_foo=bar or NPM_CONFIG_FOO=bar
    • Both are correct values but just know that inside npm-scripts npm will set its own environment variables and Node will prefer those lowercase versions over any uppercase ones you set.
    • Also you need to use underscores instead of dashes, so —allow-same-version would be npm_config_allow_same_version=true
    1. per-project: /path/to/my/project/.npmrc
    2. per-user defaults to:( $HOME/.npmrc ; also configurable via CLI option —userconfig or environment variable $NPM_CONFIG_USERCONFIG )
    3. global defaults to:( $PREFIX/etc/npmrc ; also configurable via CLI option —globalconfig or environment variable $NPM_CONFIG_GLOBALCONFIG )
    4. npm built-in configuration file: ( /path/to/npm/npmrc )

    For those who may be unfamiliar or new to Nodejs, npm and nvm the user needs to be aware that it’s possible to have more then one version of Node on your system.

    It’s also possible to have Node stored both locally and globally.

    With multiple versions and different locations it’s possible that $ which node may not give you the right location and if you run $ locate node your gonna end up with too many locations to sort through.

    Using the built-in Node/npm tools to locate Node seems to make the most sense.

    Источник

    How to set node path for nodejs (Ubuntu)

    I’m trying to setup nodejs to access a postgres database. What I’ve done so far is the following (https://gist.github.com/579814):

    echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc . ~/.bashrc mkdir ~/local mkdir ~/node-latest-install cd ~/node-latest-install curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 ./configure --prefix=~/local make install # ok, fine, this step probably takes more than 30 seconds. curl http://npmjs.org/install.sh | sh 
    git clone git://github.com/isaacs/npm.git make make install 
    Checking for program g++ or c++ : /usr/bin/g++ Checking for program cpp : /usr/bin/cpp Checking for program ar : /usr/bin/ar Checking for program ranlib : /usr/bin/ranlib Checking for g++ : ok Checking for node path : not found Checking for node prefix : ok /usr/local Checking for program pg_config : /usr/bin/pg_config 'configure' finished successfully (0.066s) Waf: Entering directory `/home/christian/node_modules/pg/build' [1/2] cxx: src/binding.cc -> build/default/src/binding_1.o ../src/binding.cc:3:25: fatal error: node_events.h: No such file or directory compilation terminated. Waf: Leaving directory `/home/christian/node_modules/pg/build' Build failed: -> task failed (err #1): binding_1.o> 

    I’ve been looking around for setting the node path, although haven’t found anything of help so far — probably also because I’m totally new to nodejs, so I’d be happy about any hint.

    Источник

    How to install node binary distribution files on Linux

    My production server (Centos 5.9) won’t compile nodejs, possibly because it’s gcc is only 4.1.2 (4.2 or above is recommended) so I’ve trying to install the binaries.

    $ wget http://nodejs.org/dist/v0.10.22/node-v0.10.22-linux-x86.tar.gz $ tar -zxvf node-v0.10.22-linux-x86.tar.gz $ cd node-v0.10.22-linux-x86 $ sudo cp bin/* /usr/local/bin $ sudo cp -R lib/* /usr/local/lib $ sudo cp -R share/* /usr/local/share 
    $ node -v # => v0.10.22 $ man node # looks fine $ npm -v # UH OH, PROBLEM - Cannot find module 'npmlog' 

    Now (keeping in mind I’m a complete beginner at node) I did some searching and found there’s an environment variable called NODE_PATH, so I tried:

    $ export NODE_PATH=/usr/local/lib/node_modules $ npm -v # SAME PROBLEM - Cannot find module 'npmlog' 
    $ find /usr/local/lib -name npmlog # => /usr/local/lib/node_modules/npm/node_modules/npmlog $ export NODE_PATH=/usr/local/lib/node_modules/npm/node_modules $ npm -v # DIFFERENT PROBLEM - Can't find '../lib/npm.js' 

    At this stage, after more unhelpful googling, I decided I was in over my depth and decided to ask for help. Can anyone tell me what I’m doing wrong?

    Comparing the linux files to those on my OSX dev machine where I had been able to install node successfully with brew, I noticed there was one file missing from /usr/local/lib/node_modules/npm and that was npmrc which contains just «prefix = /usr/local». However, adding this file to Linux had no effect.

    13 Answers 13

    It is much faster to do clean NPM reinstall which will remove «broken» links:

    wget https://npmjs.org/install.sh chmod +x install.sh sudo ./install.sh 

    Then it will ask you to remove old NPM link

    This is the easiest solution I’ve found to install both npm and node . The n package makes managing Node.js a breeze.

    Using Node Version Manager

    Use a Node version manager like nvm to handle installation and version management for you. After you install nvm you can simply install any Node version, for example nvm install 8 .

    But if you just want to install the binary yourself, see below:

    Using apt-get

    In special cases where you need a system wide Node installation, you can use apt-get:

    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs 

    The above snippet will install the latest Node 8.

    Installing the Binary Manually

    In order to install the binary manually, all you need to do is to download the binary and create a bunch of symbolic links. Execute the commands below one after the other, and it should do the job. I have also written a shell script that does it for you if that is easier (see the bottom of the answer). Hope that helps.

    Make sure to use the correct download link for your OS architecture (i.e. either 32-bit or 64-bit) for wget on the second line.

    ME=$(whoami) ; sudo chown -R $ME /usr/local && cd /usr/local/bin #adding yourself to the group to access /usr/local/bin mkdir _node && cd $_ && wget https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz -O - | tar zxf - --strip-components=1 ln -s "/usr/local/bin/_node/bin/node" .. # Making the symbolic link to node ln -s "/usr/local/bin/_node/lib/node_modules/npm/bin/npm-cli.js" ../npm ## making the symbolic link to npm 

    Here is a shell script that downloads and installs all the components. If you use this script to install Node, you can use the uninstall script to uninstall it.

    #! /bin/bash # run it by: bash install-node.sh read -p " which version of Node do you need to install: for example 8.11.4 (or any other valid version): " VERSIONNAME read -p " Are you using a 32-bit or 64-bit operating system ? Enter 64 or 32: " ARCHVALUE if [[ $ARCHVALUE = 32 ]] then printf "user put in 32 \n" ARCHVALUE=86 URL=https://nodejs.org/dist/v$/node-v$-linux-x$.tar.gz elif [[ $ARCHVALUE = 64 ]] then printf "user put in 64 \n" ARCHVALUE=64 URL=https://nodejs.org/dist/v$/node-v$-linux-x$.tar.gz else printf "invalid input expted either 32 or 64 as input, quitting . \n" exit fi # setting up the folders and the the symbolic links printf $URL"\n" ME=$(whoami) ; sudo chown -R $ME /usr/local && cd /usr/local/bin #adding yourself to the group to access /usr/local/bin mkdir _node && cd $_ && wget $URL -O - | tar zxf - --strip-components=1 # downloads and unzips the content to _node cp -r ./lib/node_modules/ /usr/local/lib/ # copy the node modules folder to the /lib/ folder cp -r ./include/node /usr/local/include/ # copy the /include/node folder to /usr/local/include folder mkdir /usr/local/man/man1 # create the man folder cp ./share/man/man1/node.1 /usr/local/man/man1/ # copy the man file cp bin/node /usr/local/bin/ # copy node to the bin folder ln -s "/usr/local/lib/node_modules/npm/bin/npm-cli.js" ../npm ## making the symbolic link to npm # print the version of node and npm node -v npm -v 
    #! /bin/bash # run it by: ./uninstall-node.sh sudo rm -rf /usr/local/bin/npm sudo rm -rf /usr/local/bin/node sudo rm -rf /usr/local/lib/node_modules/ sudo rm -rf /usr/local/include/node/ sudo rm -rf /usr/local/share/man/man1/node.1 sudo rm -rf /usr/local/bin/_node/ 

    Источник

    Читайте также:  Local privilege escalation linux kernel
Оцените статью
Adblock
detector