Using 3rd party npm registry


#1

Hi, I’m new to resin.io to deploy node applications out to devices and it’s great!

I am just having a little trouble specifying a registry for npm to use. . I’ve added a .npmrc file to my project to specify the registry, but it seems whatever I do, it’s determined to use registry.npmjs.org


#2

Hi @nickf, can you show me the relevant parts of your Dockerfile and we’ll see if we can get to the bottom of it.


#3

Hey, just checked it out, if you have a properly formatted .npmrc in your working directory, then it should work well. Yeah, if you can show us the relevant part of your Dockerfile, that would help!

In the meantime you can e.g. create an .npmrc file with the contents you’d like

registry = https://my.shiny.registry/

and then in your Dockerfile copy it to the working directory from where you are going to run the npm install. So in simplified way:

COPY .npmrc ./
RUN npm install

Alternatively you can just create the file on the fly with a line like this:

RUN echo "registry = https://my.shiny.registry/" > .npmrc
RUN npm install

I’ve tested it out, and both of these work. I’m guessing that you are not copying the .npmrc file into the container, that’s why it doesn’t find it. The explicit copy should work.

Let us know how it goes!


#4

Thanks for your replies. I’m not using my own Docker file, just uploading a plain old node project, and letting resin do it’s thing. I’ll look at writing a Dockerfile to do this.


#5

Yes, checked it out, the nodeJS basic project does not pull in .npmrc, making a note for it! :pencil2:

In the meantime you can check out this example of a node project, shouldn’t require too much boilerplate!


#6

That worked a charm. The .npmrc is not copied over until after the npm install - too late for me!

I just copied the Dockerfile.template from the simple-server-node project and added the

before the npm install.
Thanks again for your help.