RHMAP Environments
fh-npm
Rationale
package.json
file. It was developed by the RHMAP team to solve a few problems. Older versions of npm were relatively slow at installing dependencies & didn't make great use of the npm cache. Doing a lot of npm installs at the same time can be CPU intensive, so caching pre-built binaries was one of its goals. Also, the amount of disk usage would be relatively high (inodes usage) due to a large number of small files. Some of these problems have been addressed in later versions of npm, and fh-npm is becoming less necessary.Opting out of fh-npm
npm-shrinkwrap.json
file to the root of your application will tell Dynofarm to bypass fh-npm, and use npm instead. This will force you to have your dependencies locked down, as npm will only install the dependencies and versions in your npm-shrinkwrap.json
file. The main caveat with doing this is the amount of time to install dependencies, in particular, anything that has to be compiled, as none of the caching that fh-npm providers will be used.npm-shrinkwrap.json
file. This can be useful in the early stages of development where you may not want to lock down versions yet. To do this, add an empty npm-shrinkwrap.json
file, and a .npmrc
file to the root of your application. Add the following to the .npmrc
file.shrinkwrap=false
npm-shrinkwrap.json
file. Only modules in the package.json
will be installed.Peer Dependencies
"peerDependencies": { "grunt": ">=0.4.0" }
Scoped & private dependencies
Scoped dependencies are not supported by fh-npm. However, like peer dependencies, if you bypass fh-npm, scoped dependencies should work as normal. They should work with the version of npm used in Node.js 4 environments, but not 0.10 environments. Here is an example of a scoped dependency.
"dependencies":{ "@namespace/mypackage":"~1.0.0" }
The scoped package can be used by required it:
var mypackage = require("@namespace/mypackage");
If a scoped module is also private, an extra step is required to allow that module to be downloaded. An authToken of a user that has accessed the private module can be added to the .npmrc
file in the root of the repo.
//registry.npmjs.org/:_authToken=SOME_AUTH_TOKEN
This token gets used by npm for any private modules in the specified registry. To generate an auth token, login to npm on any machine, then check the ~/.npmrc
file for the token line. Tokens can be invalidated by changing your npm password or logging out on the same machine with npm logout
.
Future Node.js versions in Dynofarm
From Node.js 6.x onwards, fh-npm will no longer be used in Dynofarm. This is due to various changes to npm since version 2, which fh-npm is based on. The layout of the node_modules
folder has changed to a flatter structure. This, combined with various performance improvements, has lessened the reasons for fh-npm.
Red Hat Mobile Application Platform is available for download, and you can read more at Red Hat Mobile Application Platform.
Last updated: February 23, 2024