npm private modules error

1.4k Views Asked by At

I've couple of private modules that are not on the npm site and I'd like to use them in my application but running in couple of issues while uploading at Elasticbeanstalk. (Elastic beanstalk runs it's npm install after each upload).

  1. The AWS complained initially that it couldn't find those private modules on NPM, so I removed their entries from package.json file.

  2. Once I removed, I uploaded the application again with node_modules folder having those packages then AWS start to complain

    Error: Cannot find module 'my-private-module-name'
    

I'm wondering how private modules work so I don't have to go through NPM at least for deployment or as a last resort I'll publish them.

Edit

"dependencies": {
    "body-parser": "^1.12.4",
    "express": "^4.12.3",
    "multer": "^0.1.8",
    "mustache": "^2.0.0",
    "mysql": "^2.6.2",
    "my-private-module": "^1.0.5",
    "redis": "^0.12.1",
    "socket.io": "^1.3.3"
  },
1

There are 1 best solutions below

0
On

You will need to have an internal way of publishing packages if you wish to not have certain packages looked up on npm.

In your individuals packages you will need to add "publishConfig":{"registry":"http://my-internal-registry.local"} to the package.json file.

This will allow you to look up packages at that location as opposed to going directly to NPM.

https://docs.npmjs.com/misc/registry

Then in your ~/.npmrc file you can specify a registry that npm will use first prior to looking up modules on npm.