I have developed my first Node.js pp. For now, it just sits on my laptop.
During development I had to install some modules:
npm install socket.io
npm install mysql@2.0.0-alpha3
npm install iniparser
npm install js-yaml
npm install nodemailer
I have installed all of them “per-project”, not globally.
The directory of my project looks like this (my code is all in push_server.js):
|
|--- push_server.js
|
|--- node_modules
|--- iniparser
|--- js-yaml
|--- mysql
|--- socket.io
|--- nodemailer
Now I want to push this project to the production server.
My question is: can I upload the whole codebase (including installed modules) or should I upload just the code of my app and re-install the modules one-by-one on the server?
Note: my dev machine runs Ubuntu 10.04, the production server runs CentOS 5.3
I think all those modules are made up of js files only, therefore it should be allright.
However, is it possible that a module installed by npm compiles some code on the local machine, therefore that code is likely not to work on another machine. Also, how can I know whether a module does that?
Hope the question is not too silly – I have just started with Node.js.
Thanks.
I always try to use the latest versions of the required modules. Node.js is still very young and whenever a module is updated it often brings bugfixes, speed improvements, etc. I install modules locally, test my code on them and finally use them in production. When you install them with
npm install module --savethey are automatically added to yourpackage.jsonfile asdependencies.Using
gitfor version control and deployment I usually put thenode_modulesfolder into my.gitignorefile. It is therefore not uploaded to my server. On the server you just have to runnpm installto install all your required modules, which is much faster than installing them one by one.This workflow is also used by heroku.