question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Verdaccio private proxy "npm install" won't function offline

See original GitHub issue

Hello,

I have been working on this for several days and coming up with a custom Verdaccio setup on Docker so it is can be used with the project I’m working on. The key requirement here that is unique is the environment for this project is on an offline network for security reasons. I have cached all of the required NPM packages using https://www.npmjs.com/package/npm-offline-packager

However, no matter what I try I can’t get Verdaccio to work when there is no internet connection (offline). I have a duplicate test environment setup in the cloud with the same Linux OS so I can test with and without internet so I can confirm it is working when online.

Environment:

CentOS 6.9 Docker version 1.7.1, build 786b29d

I’m using the latest Verdaccio container from Docker Hub. The reason I have to use Docker 1.7.1 is because that is the latest version of Docker that works and is stable with CentOS 6.9. However, the Verdaccio Docker container appears to be running and functioning perfectly fine on here when internet is connected on my testing environment.

here is my Verdaccio config.yaml file:

#
# This is the config file used for the docker images.
# It allows all users to do anything, so don't use it on production systems.
#
# Do not configure host and port under `listen` in this file
# as it will be ignored when using docker.
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
#

# path to a directory with all packages
storage: /verdaccio/storage
# path to a directory with plugins to include
plugins: /verdaccio/plugins

listen:
    0.0.0.0:4873

auth:
  htpasswd:
    file: /verdaccio/conf/htpasswd
    # Maximum amount of users allowed to register, defaults to "+inf".
    # You can set this to -1 to disable registration.
    #max_users: 1000
security:
  api:
    jwt:
      sign:
        expiresIn: 60d
        notBefore: 1
  web:
    sign:
      expiresIn: 7d

# a list of other known repositories we can talk to
uplinks:
  private:
    url: 0.0.0.0:4873

packages:
  '@nrydevops/*':
      access: $all
      publish: $all
      proxy: private
      allow_offline: true

  '@*/*':
    # scoped packages
    access: $all
    publish: $all
    proxy: private
    allow_offline: true

  '**':
    # allow all users (including non-authenticated users) to read and
    # publish all packages
    #
    # you can specify usernames/groupnames (depending on your auth plugin)
    # and three keywords: "$all", "$anonymous", "$authenticated"
    access: $all

    # allow all known users to publish packages
    # (anyone can register by default, remember?)
    publish: $all

    # if package is not available locally, proxy requests to 'npmjs' registry
    proxy: npmjs

# To use `npm audit` uncomment the following section
middlewares:
  audit:
    enabled: true

# log settings
logs:
  - {type: stdout, format: pretty, level: trace}
  #- {type: file, path: verdaccio.log, level: info}

The docker run command I am using is:

docker run -v ~/verdaccio/storage/:/verdaccio/storage/ -v ~/verdaccio/storage.tar:/verdaccio/storage.tar -v ~/verdaccio/conf/:/verdaccio/conf/  -p 4873:4873 {Container Image ID}

I can docker exec into the container and confirm that the (storage, conf, and storage.tar) are going into the correct directory inside the Verdaccio container.

Steps to reproduce the issue: -with above config and with internet connected I run:

npm install --registry http://localhost:4873/

Verdaccio works as expected and pulls the NPM modules from the tarballs in the cached storage.

-IMPORTANT STEP: -I enable some firewall rules on the cloud server test environment which disabled public internet. -I can still do: curl http://localhost:4873/ and I get the Verdaccio web GUI html output -I can also ping the CentOS 6.9 server where the Verdaccio server is running from my Node client machine on the same local network. I can ping the CentOS host server from my Node client machine as well. All local network traffic is working fine.

For some reason Verdaccio fails and will not pull the NPM modules from the Verdaccio storage and eventually the “npm install” command fails with:

error--- unexpected error: connect ETIMEDOUT 104.16.19.35:443
Error: connect ETIMEDOUT 104.16.19.35:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
 http <-- 500, user: null(10.150.0.23), req: 'POST /-/npm/v1/security/audits/quick', error: internal server error
 error--- unexpected error: connect ETIMEDOUT 104.16.16.35:443
Error: connect ETIMEDOUT 104.16.16.35:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
 http <-- 500, user: null(10.150.0.23), req: 'POST /-/npm/v1/security/audits/quick', error: internal server error

Here is a sample of the output when internet is connected and Verdaccio is functioning as it is expected:

trace--- [local-storage/getPackageStorage]: storage path: /verdaccio/storage/object-visit
 debug--- [local-storage/readPackage] read a package: object-visit
 trace--- [local-storage/_readStorageFile] read a file: /verdaccio/storage/object-visit/package.json
 info <-- 10.150.0.23 requested 'GET /has-values'
 trace--- [middleware/allow][access] allow for undefined
 trace--- allow access for has-values
 trace--- [auth/allow_action]: user: undefined
 trace--- [auth/allow_action]: hasPermission? true for user: undefined
 trace--- auth/allow_action: access granted to: undefined
 trace--- allowed access for has-values
 trace--- [local-storage/getPackageStorage]: storage selected: /verdaccio/storage
 trace--- [local-storage/getPackageStorage]: storage path: /verdaccio/storage/has-values
 debug--- [local-storage/readPackage] read a package: has-values
 trace--- [local-storage/_readStorageFile] read a file: /verdaccio/storage/has-values/package.json
 trace--- [local-storage/_readStorageFile] read file succeed: /verdaccio/storage/object-copy/package.json
 trace--- [local-storage/readPackage/_readStorageFile] read a package succeed: object-copy
 http <-- 304, user: null(10.150.0.23), req: 'GET /object-copy', bytes: 0/0
 trace--- [local-storage/_readStorageFile] read file succeed: /verdaccio/storage/map-visit/package.json
 trace--- [local-storage/readPackage/_readStorageFile] read a package succeed: map-visit
 http <-- 304, user: null(10.150.0.23), req: 'GET /map-visit', bytes: 0/0
 trace--- [local-storage/_readStorageFile] read file succeed: /verdaccio/storage/has-values/package.json
 trace--- [local-storage/readPackage/_readStorageFile] read a package succeed: has-values
 http <-- 304, user: null(10.150.0.23), req: 'GET /has-values', bytes: 0/0
 trace--- [local-storage/_readStorageFile] read file succeed: /verdaccio/storage/object-visit/package.json
 trace--- [local-storage/readPackage/_readStorageFile] read a package succeed: object-visit
 http <-- 304, user: null(10.150.0.23), req: 'GET /object-visit', bytes: 0/0
 info <-- 10.150.0.23 requested 'GET /has-values'
 trace--- [middleware/allow][access] allow for undefined
 trace--- allow access for has-values
 trace--- [auth/allow_action]: user: undefined
 trace--- [auth/allow_action]: hasPermission? true for user: undefined
 trace--- auth/allow_action: access granted to: undefined
 trace--- allowed access for has-values
 trace--- [local-storage/getPackageStorage]: storage selected: /verdaccio/storage
 trace--- [local-storage/getPackageStorage]: storage path: /verdaccio/storage/has-values
 debug--- [local-storage/readPackage] read a package: has-values
 trace--- [local-storage/_readStorageFile] read a file: /verdaccio/storage/has-values/package.json
 trace--- [local-storage/_readStorageFile] read file succeed: /verdaccio/storage/has-values/package.json
 trace--- [local-storage/readPackage/_readStorageFile] read a package succeed: has-values
 http <-- 304, user: null(10.150.0.23), req: 'GET /has-values', bytes: 0/0
 info <-- 10.150.0.23 requested 'GET /copy-descriptor'
 trace--- [middleware/allow][access] allow for undefined
 trace--- allow access for copy-descriptor
 trace--- [auth/allow_action]: user: undefined
 trace--- [auth/allow_action]: hasPermission? true for user: undefined
 trace--- auth/allow_action: access granted to: undefined
 trace--- allowed access for copy-descriptor
 trace--- [local-storage/getPackageStorage]: storage selected: /verdaccio/storage
 trace--- [local-storage/getPackageStorage]: storage path: /verdaccio/storage/copy-descriptor
 debug--- [local-storage/readPackage] read a package: copy-descriptor
 trace--- [local-storage/_readStorageFile] read a file: /verdaccio/storage/copy-descriptor/package.json
 trace--- [local-storage/_readStorageFile] read file succeed: /verdaccio/storage/copy-descriptor/package.json
 trace--- [local-storage/readPackage/_readStorageFile] read a package succeed: copy-descriptor
 http <-- 304, user: null(10.150.0.23), req: 'GET /copy-descriptor', bytes: 0/0
 info <-- 10.150.0.23 requested 'POST /-/npm/v1/security/audits/quick'

As you can see it is working as expected with internet and that is the only difference. Isn’t Verdaccio supposed to be able to work in “Offline Mode” ?

I greatly appreciate any help with this as I have been working on it for several days and I really need to get it working. Thank you in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

0reactions
lock[bot]commented, Apr 2, 2020

🤖This thread has been automatically locked 🔒 since there has not been any recent activity after it was closed. We lock tickets after 90 days with the idea to encourage you to open a ticket with new fresh data and to provide you better feedback 🤝and better visibility 👀. If you consider, you can attach this ticket 📨 to the new one as a reference for better context. Thanks for being a part of the Verdaccio community! 💘

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - How to create offline private registry of verdaccio
Run verdaccio $> verdaccio · Be sure you are online · Run npm install --registry="http://localhost:4873 · When the finish to install, inspect your ......
Read more >
Configuration File - Verdaccio
By default verdaccio does not allow you to publish packages when the client is offline. This can be can be overridden by setting...
Read more >
verdaccio-offline-storage - npm
This storage plugin provides only the packages versions stored in a local-storage storage. This means that if you are in an offline environment ......
Read more >
Five use cases where a npm private proxy fits in your workflow
As offline installation ... These days the solution to offline mode is called yarn and lately npm@5.x . It's a valid argument, both...
Read more >
Create a free private npm registry with Verdaccio - ITNEXT
The last line makes our registry act as a proxy to the public npm registry in case a user tries to access a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found