I previously had an issue with my node.js app on Heroku. I added the dependency into my package.json and now it is working. But, is this the best way to do it?
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "3.4.4",
"jade": "*",
"stylus": "*",
"ejs": "0.8.5"
},
"engines": {
"node": "0.10.1",
"npm": "1.3.14"
}
}
I ask because the other dependencies have a “*” which were there by default in my express app. What exactly does that mean and am I fine with leaving this file the way it is?
The *
means that any version is fine. When running npm install
(what Heroku does when pushing your solution) npm is going to get the latest version of the appropriate module.
This is usually not what you want because a new module version may break your existing code base. It’s way better if you put fixed version numbers into your package.json
file.
This still does not necessarily solve all potential issues (because you can not control what the module you require require for themselves), but it helps a lot. To really solve this issue you need to think about how to package your application including the modules you depend on. If you Google for this, you should find lots of results on how to do this.
Hope this helps.