Adding node to path linux

Node Bash path confusion on Ubuntu 16 using n

I tried to install n for node version updates following this answers direction. It was successful in upgrading me to node v7 but had a side effect. Node is now found:

If I type node -v I get a bash error because it’s looking in the wrong place (it looks in usr/bin/node ). What is my best path forward? How do I change the path where my terminal looks for node so I can run node index.js while not interfering with my desire to use n to upgrade node in the future. I’m not sure if this is relevant but, when I’m in a project and I type nodemon index.js everything works as expected. I think that this is due to the fact that nodemon is installed where node v7 is installed. Here is the value of echo $PATH :

 /usr/local/heroku/bin:/home/devin/.rbenv/shims:/home/devin/.rbenv/bin:/usr/bin:/home/devin/bin:/home/devin/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin 
 /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/node.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/outer_join.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/over.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/regexp.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/right_outer_join.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/select_core.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/select_statement.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/sql_literal.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/string_join.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/table_alias.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/terminal.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/true.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/unary.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/unary_operation.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/unqualified_column.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/update_statement.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/values.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/window.rb /var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/with.rb /var/lib/gems/2.3.0/gems/execjs-2.7.0/lib/execjs/support/node_runner.js /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node.c /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node.h /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node.o /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node_set.c /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node_set.h /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node_set.o /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/css/node.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/node /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/node.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/node_set.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/node/save_options.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/pp/node.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/html/test_node.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/html/test_node_encoding.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/node /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_node.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_node_attributes.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_node_encoding.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_node_inheritance.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_node_reparenting.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_node_set.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_unparented_node.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/node/test_save_options.rb /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/node/test_subclass.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/script/tree/node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/at_root_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/charset_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/comment_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/content_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/css_import_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/debug_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/directive_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/each_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/error_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/extend_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/for_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/function_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/if_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/import_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/keyframe_rule_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/media_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/mixin_def_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/mixin_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/prop_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/return_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/root_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/rule_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/supports_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/trace_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/variable_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/warn_node.rb /var/lib/gems/2.3.0/gems/sass-3.4.22/lib/sass/tree/while_node.rb 

Источник

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.

Читайте также:  Charset utf 8 linux

Источник

Adding node to path linux

# Adding Node.JS to the system path ###### tags: `Environment Variables` `Path` *Posted 2022-07-04* — [For Windows Users](#Windows-Users) [For Linux users](#Linux-Users) ## Windows Users Open the start menu and write «path». The following option should show up, click it. windows environment variables

Image 1: System environment variables

This opens the window for system properties. Click «Environment Variables. » to continue. windows environment variables

Image 2: System properies window

While you can add the path to only your user, Node.JS is used in many other applications and I strongly advice adding it to the **system variables** instead of **user variables**. Select «PATH» and click «Edit. » windows environment variables

Image 3: Environment variables window

Finally just press «New» and input the path to your Node.JS installation in the new field under the already existing ones. windows environment variables

Image 4: Edit variables window

Now just press OK, OK, then, you guessed it, OK, and you’re done! ## Linux Users For Linux, literally execute the a single BASH command in the terminal of your liking: «`bash export PATH=$PATH:/usr/local/nodejs/bin «`

Sign in

By clicking below, you agree to our terms of service.

Источник

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:

Читайте также:  Astra linux настройка fstab

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.

    Источник

Оцените статью
Adblock
detector