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

前端 未结 4 583
北海茫月
北海茫月 2021-02-01 08:45

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 i

4条回答
  •  無奈伤痛
    2021-02-01 09:21

    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

提交回复
热议问题