简体   繁体   中英

node.js in production environment

I have to set-up node environment in my production system. I installed node in my local system its fine, after that i checked for version node -v .

Now i installed node in my production system using sudo apt get install nodejs and now i checked the version node -v nothing happened but i used nodejs -v , its working.

Also in my local system i used node filename.js to run my node app. But in my production system i have to use nodejs filename.js . I dont know why this happening? Also whether it will create problem in my production. Please share your ideas.

This is because your particular distribution of linux already has a node binary.

You're more than likely not using it for anything. You have two options.

  1. rename the pre-installed node to something else, and rename nodejs to node
  2. rename nodejs to node but make sure to adjust your $PATH so that node.js's directory is loading before the pre-installed node

It's more linux specific question. You can create a symlink to use node instead of nodejs . Command example here:

sudo ln -sT $(which nodejs) /usr/local/bin/node

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM