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 [email protected]
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.
You should definitely copy node_modules if possible.
If you re-download them at the server, you run a risk of getting slightly different versions of the modules in use. Even if you require a strict module version X, that module can again have wildcard dependencies to other modules Y Z. This means that if Y is updated and you publish to the server, it will now run using different code for Y than what you used for your local testing and validation.
In some cases you may not even have a required module available at deployment time, because the author has decided to de-publish the package for whatever reason.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With