linux下.js文件,Linux下node.js文件目录

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

# Answer 1

4d350fd91e33782268f371d7edaa8a76.png

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.

# Answer 2

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

which node

If it doesn't succeed, try this one:

which nodejs

Same thing for finding npm installation path:

which npm

If you are on Windows, write where instead of which

Hope, it helps :)

# Answer 3

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:

install package manager npm: sudo apt-get install npm

then upgrade npm: sudo npm cache clear --force && sudo npm install -g npm

next install n: sudo npm install -g n which is a version manager vor node.

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

# Answer 4

If you have both

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:

--save-dev, --prefix, --global

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

four relevant files:

per-project: /path/to/my/project/.npmrc

per-user defaults to:( $HOME/.npmrc ; also configurable via CLI option --userconfig or environment variable $NPM_CONFIG_USERCONFIG )

global defaults to:( $PREFIX/etc/npmrc ; also configurable via CLI option --globalconfig or environment variable $NPM_CONFIG_GLOBALCONFIG )

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值