node.js - AWS EC2, NodeJS - cannot find module -
i have nodejs installed , running on aws ec2. utilize script automatically start it. works fine. want install instance of same application - under separate folder , listens on different port. after sec install have got 2 separate node projects: - /var/nodes/fc-dev - dev node , - /var/nodes/fc-prod - production node create separate script production module - /etc/init/fc-prod.conf here /etc/init/fc-dev.conf script: # saves log /var/log/upstart/fc-dev.log console log
# starts after drives mounted. start on started mountall stop on shutdown # automatically respawn. fail permanently if respawns 10 times in 5 seconds: respawn respawn limit 10 5 script exec sudo node_env=development /usr/bin/node --debug /var/nodes/fc-dev/fc-server.js end script and here /etc/init/fc-prod.conffile:
# saves log /var/log/upstart/fc-dev.log console log # starts after drives mounted. start on started mountall stop on shutdown # automatically respawn. fail permanently if respawns 10 times in 5 seconds: respawn respawn limit 10 5 script exec sudo node_env=production /usr/bin/node /var/nodes/fc-prod/fc-server.js end script i start dev project sudo start fc-dev, when type sudo start fc-prod, have got next error:
module.js:340 throw err; ^ 'rror: cannot find module '/var/nodes/fc-prod/fc-server.js @ function.module._resolvefilename (module.js:338:15) @ function.module._load (module.js:280:25) @ function.module.runmain (module.js:497:10) @ startup (node.js:119:16) @ node.js:906:3 on other hand, typing sudo node_env=production /usr/bin/node /var/nodes/fc-prod/fc-server.js allows me start production node. doing wrong?
after additional attempts , fails solved issue follow: sudo cp fc-dev.conf fc-prod.cp sudo nano fc-prod.conf - , edit file removing debug related parameter , changing destination folder production one. compared both file versions of production config files , differences have got special chars - lfcr , lf hope helps in future.
node.js ubuntu amazon-ec2
No comments:
Post a Comment