If you’re using npm to manage your Node.js application dependencies, you might want to be aware of how Node.js handles environments.
Node.js uses two global variables to manage your dependencies: npm_version defines the version of Node.js defines the version of Node.js :npm_revision_id defines the id of the NPM version that you’re using
You can’t change your version without restarting your server!
Also, NPM is very strict about maintaining the version number of your dependencies — the number of versions they support is very limited.
The current version is always between v0.12 and v0.17 of the Node.js API. Example of a version locking issue: “dependencies”: { “express”: “3.4.x” } The above example would be vulnerable to a versions lock-in, because if you update your NPM version to v0.16 but the Express dependency hasn’t been updated yet, you would have to manually change the dependency for every single module in your application!
You would have no choice but to restart your server and wait for everything to reload. This can cause major downtime on your servers and simply isn’t practical in production. The key to avoiding this issue is simple: never depend on a specific version of a package. Instead, use ranges in your dependency specification like so: “dependencies”: { “express”: “3.x” }
Now, even if you update your NPM version to v0.16 (without updating your Express dependency), you won’t be locked in because the version specifier will ensure that any updates are compatible with the existing dependencies in your application.
If you would like to use the latest NPM version possible for your application, set the :npm_revision_id to 0, as shown in the following example: “dependencies”: { “express”: “3.x”, “jade”: “*”, “stylus-node-plugins”: “@latest” } You can use this approach if you are okay with potentially being locked into a specific set of versions.
This might work for internal applications or open source projects, but it is not recommended that you use this approach for production environments. Conclusion Node.js is a powerful platform with a vibrant ecosystem and an active community.
It’s easy to get started developing for Node.js, and you can quickly build high-performance applications that run on a variety of platforms, including Windows, OS X, and Linux.
If your application needs to handle high levels of traffic or large amounts of data, then you should consider using Node.js for your back-end processing in order to scale independently from your front-end application stack.
Jira
Introduction to the Agile Mindset
Here’s a quick introduction to the Agile Mindset: Download Agile Manifesto File at the bottom of the page. (00:13) The mindset is the values and principles that Agile comes from to develop a high-quality product. Read more…
0 Comments