Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Working with peer, scoped and private npm dependencies in RHMAP

June 13, 2017
David Martin
Related topics:
Node.js
Related products:
Red Hat build of Node.js

    RHMAP Environments

    An RHMAP Environment provides a Node.js runtime for Mobile Backends. There are 2 environment types: Dynofarm & OpenShift. The former is an LXC based PaaS, written in Node.js & bash. It is superseded by OpenShift environments. However, there are still many Dynofarm environments in use in the RHMAP SaaS offering.

     

    fh-npm

    Rationale

    fh-npm is a wrapper for npm. It is only used in Dynofarm environments to install npm dependencies specified in a 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.
     
    There are features of newer versions of npm that are not supported by fh-npm. This imposes restrictions on what developers can use in their Node.js application. However, it is possible to use these newer features by opting out of fh-npm and triggering the use of an npm version compatible with the version of Node.js being deployed to.

    Opting out of fh-npm

    Adding an 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.
     
    It is possible to bypass fh-npm and not have to maintain an 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
    This combination of files will bypass fh-npm, and tell npm to ignore the npm-shrinkwrap.json file. Only modules in the package.json will be installed.

    Peer Dependencies

    Peer dependencies are not supported by fh-npm. However, if you bypass fh-npm, peer dependencies should work as normal for Node.js 4 environments. Peer dependencies are not supported by the version of npm used in Node.js 0.10 environments. Here is an example of a peer dependency that a grunt plugin might use.
    "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

    Recent Posts

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.