craftship / codebox-npm

Serverless private npm registry using https://serverless.com/

Home Page:http://codebox.sh/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't find published or proxied packages

hassankhan opened this issue Β· comments

This is a Bug Report

Description

For bug reports:

  • What went wrong?
    I wasn't able to run npm i in my project.

  • What did you expect should have happened?
    It should have installed my project's dependencies successfully.

  • What was the config / env variables you used?

  • What stacktrace or error message did you
    experience?

$ npm i myprivpackage -S
npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/cainaleao/.nvm/versions/node/v4.6.0/bin/node" "/Users/hassankhan/.nvm/versions/node/v4.6.0/bin/npm" "i" "myprivpackage" "-S"
npm ERR! node v4.6.0
npm ERR! npm  v3.10.9
npm ERR! code E403

npm ERR! Registry returned 403 for GET on https://XXXXXXXXX.execute-api.eu-west-1.amazonaws.com/prod/registry/myprivpackage
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Development/Sandbox/testnode/npm-debug.log

$ npm i lodash -S
npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/hassankhan/.nvm/versions/node/v4.6.0/bin/node" "/Users/cainaleao/.nvm/versions/node/v4.6.0/bin/npm" "i" "lodash" "-S"
npm ERR! node v4.6.0
npm ERR! npm  v3.10.9
npm ERR! code E403

npm ERR! Registry returned 403 for GET on https://XXXXXXXXX.execute-api.eu-west-1.amazonaws.com/prod/registry/lodash
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Development/Sandbox/testnode/npm-debug.log

Additional Data

  • NPM CLI version you are using: 3.10.9
  • Serverless version you're using: 1.8.0
  • Node version you're using: 4.6.0

Also tested on:

  • NPM CLI version you are using: 3.10.10
  • Serverless version you're using: 1.8.0
  • Node version you're using: 6.7.0

I also tried scoping the package, but it made no difference whatsoever 😒

This is saying for some reason that you are not authenticated for the registry it is pointing at, did you manage to do a successful npm login before npm i. Need only to be done once per registry url.

Just double check that it is the correct registry url as well npm get registry and not being overridden by a .npmrc file or something.

Just deployed a fresh registry from master using the GitHub API, my .env file as follows:

export CODEBOX_REGION="eu-west-2"
export CODEBOX_ADMINS="jonsharratt"
export CODEBOX_REGISTRY="https://registry.npmjs.org/"
export CODEBOX_BUCKET="my-codebox"
export CODEBOX_GITHUB_URL="https://api.github.com/"
export CODEBOX_GITHUB_CLIENT_ID="client_id_here"
export CODEBOX_GITHUB_SECRET="secret_here"

source .env

Worth double checking your env vars are set correctly for you Lambdas in the AWS console as well.

Have just tested with and without being an admin and npm i seems to be working for me just now. πŸ™ˆ

Can install public and private packages correctly.

My env vars are as follows:

export CODEBOX_REGION="eu-west-1"
export CODEBOX_ADMINS="hassankhan"
export CODEBOX_REGISTRY="https://registry.npmjs.org/"
export CODEBOX_BUCKET="npm-registry-storage" 
export CODEBOX_GITHUB_URL="https://api.github.com/" 
export CODEBOX_GITHUB_CLIENT_ID="XXX" 
export CODEBOX_GITHUB_SECRET="XXX" 
export CODEBOX_RESTRICTED_ORGS="MyOrg"

I've just followed the instructions to the T and redeployed, I can't even get it to work on my own machine directly after publishing the package.

To clarify:

$ sls install --url https://github.com/craftship/codebox-npm/tree/0.12.1 --name npm-registry
$ cd npm-registry
$ export CODEBOX_REGION="eu-west-1"
$ export CODEBOX_ADMINS="hassankhan"
$ export CODEBOX_REGISTRY="https://registry.npmjs.org/"
$ export CODEBOX_BUCKET="npm-registry-storage" 
$ export CODEBOX_GITHUB_URL="https://api.github.com/" 
$ export CODEBOX_GITHUB_CLIENT_ID="XXX" 
$ export CODEBOX_GITHUB_SECRET="XXX" 
$ export CODEBOX_RESTRICTED_ORGS="MyOrg"

I then went to the project I want to publish and added an .npmrcfile with the following:

registry=https://XXXX.execute-api.eu-west-1.amazonaws.com/prod/registry
always-auth=true

Followed by running npm login and npm publish, which worked successfully. I then went to the consuming project, added the same .npmrc and tried to npm install it, which resulted in the stack traces.

Ah I think I know what it might be....

If you head to:
https://github.com/settings/applications?o=used-desc

Go to the application for GitHub and grant access to allow the app to read your organisation.

I have a task to get a proper site together for the documentation as there is quite a lot to all of this stuff now.

Oh my god, I'm so sorry!! I was stupidly using the Client ID and secret from the wrong organisation! Going to correct that, will update here shortly.

Ha, no worries we all do it - is a classic πŸ‘ the above may still apply though as I had to grant explicit access for my craftship organization in GitHub to use the CODEBOX_RESTRICTED_ORGS feature that has gone in today.

image

Had to grant it once I had attempted to make a call to the registry e.g. npm info react, think I need to look into that a bit more to see if can be programatically give access correctly without a manual step.

YAAAAY!!!! πŸŽ‰πŸŽ‰πŸŽ‰πŸŽ‰ Just tested it on two different machines, all seems to be working, thanks for being so patient πŸ˜„