drone-plugins / drone-npm

Drone plugin for publishing packages to NPM
http://plugins.drone.io/drone-plugins/drone-npm
Apache License 2.0
20 stars 18 forks source link

MyPackage 'is not in the npm registry.' #34

Closed brenwell closed 6 years ago

brenwell commented 6 years ago

Hey there, thanks for the lib!

I was hoping you could help me diagnose my issue publishing. It says its not an npm registry but it exists and I have publish 12 versions there. Any ideas??

https://www.npmjs.com/package/each-after

Cheers

+ npm --version
time="2018-03-10T12:21:41Z" level=info msg="Specified credentials" email="$NPM_EMAIL" username="$NPM_USERNAME" 
time="2018-03-10T12:21:41Z" level=info msg="Writing npmrc" path="/root/.npmrc" 
3.10.10
+ npm config set always-auth true
+ npm whoami
$NPM_USERNAME
time="2018-03-10T12:21:44Z" level=info msg="No registry specified in the package.json" 
time="2018-03-10T12:21:44Z" level=info msg="Found package.json" name=each-after version=1.0.12 
+ npm view each-after versions --json
time="2018-03-10T12:21:45Z" level=info msg="Version not found in the registry" 
time="2018-03-10T12:21:45Z" level=info msg="Publishing package" 
+ npm publish
npm ERR! publish Failed PUT 404
npm ERR! Linux 4.4.0-72-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "publish"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code E404

npm ERR! 404 Not Found : each-after
npm ERR! 404 
npm ERR! 404  'each-after' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! Please include the following file with any support request:
npm ERR!     /drone/src/github.com/brenwell/each-after/npm-debug.log
exit status 1

.drone.yml

---
pipeline:
  build:
    image: node:8
    commands:
      - npm install
      - npm build
      - npm test

  npm:
    image: plugins/npm
    username: $NPM_USERNAME
    password: $NPM_PASSWORD
    email: $NPM_EMAIL

docker-compose.yml


version: '2'

services:
  drone-server:
    image: drone/drone:0.8
    ports:
      - 8822:8000
      - 9000:9000
    volumes:
      - /var/lib/drone:/var/lib/drone/
    restart: always
    environment:
      ...
      - NPM_USERNAME=brenwell
      - NPM_PASSWORD=somepassword
      - NPM_EMAIL=my@email.com

package.json

{
  "name": "each-after",
  "version": "1.0.12",
  "description": "Iterate through an array with an interval between each call. Stop & kill iteration.",
  "main": "lib/each-after.js",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "start": "npm run build && npm test",
    "lib": "npm run build && npm run min",
    "build": "babel index.js -o ./lib/each-after.js -s inline",
    "min": "minify index.js -o ./lib/each-after.min.js",
    "test": "npm run unit && npm run lint",
    "unit": "mocha",
    "lint": "eslint index.js --fix",
    "prepublishOnly": "npm run lib && npm test"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/brenwell/each-after.git"
  },
  "keywords": [
    "iteration",
    "loop",
    "array",
    "delay",
    "stop",
    "kill"
  ],
  "author": "Brendon Blackwell",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/brenwell/each-after/issues"
  },
  "homepage": "https://github.com/brenwell/each-after#readme",
  "devDependencies": {
    "@babel/cli": "^7.0.0-beta.35",
    "@babel/core": "^7.0.0-beta.35",
    "@babel/preset-env": "^7.0.0-beta.35",
    "babel-minify": "^0.2.0",
    "chai": "^4.1.2",
    "eslint": "^4.13.1",
    "mocha": "^4.0.1",
    "sinon": "^4.1.3"
  }
}
tboerger commented 6 years ago

You should look into http://docs.drone.io/manage-secrets/, the injection of the env variables won'T work like that, you inject the env variables into the drone server, but the drone agent starts the build environments and it doesn't inject any env variable available to the server or the agent.

brenwell commented 6 years ago

Yep, just found that, sorry for being stupid and wasting your time. Thanks for getting back to me.

While I have you here, Is there a best practise for bumping the version in order to publish?

And I noticed that if there is an existing version the plugin fails silently

Version exists

+ npm --version
time="2018-03-12T10:14:16Z" level=info msg="Specified credentials" email="my@email.com" username=brenwell 
time="2018-03-12T10:14:16Z" level=info msg="Writing npmrc" path="/root/.npmrc" 
3.10.10
+ npm config set always-auth true
+ npm whoami
brenwell
time="2018-03-12T10:14:19Z" level=info msg="No registry specified in the package.json" 
time="2018-03-12T10:14:19Z" level=info msg="Found package.json" name=each-after version=1.0.13 
+ npm view each-after versions --json

Version doesn't exist

+ npm --version
time="2018-03-12T10:16:02Z" level=info msg="Specified credentials" email="my@email.com" username=brenwell 
time="2018-03-12T10:16:02Z" level=info msg="Writing npmrc" path="/root/.npmrc" 
3.10.10
+ npm config set always-auth true
+ npm whoami
brenwell
time="2018-03-12T10:16:05Z" level=info msg="No registry specified in the package.json" 
time="2018-03-12T10:16:05Z" level=info msg="Found package.json" name=each-after version=1.0.14 
+ npm view each-after versions --json
time="2018-03-12T10:16:06Z" level=info msg="Version not found in the registry" 
time="2018-03-12T10:16:06Z" level=info msg="Publishing package" 
+ npm publish
+ each-after@1.0.14

I would suggest adding something like

level=info msg="Version found in the registry"
level=info msg="Not Publishing package" 

What do you think?

Thanks again

tboerger commented 6 years ago

That's something where @donny-dont can give more information I guess.

donny-dont commented 6 years ago

The npm plugin was written in a way that it would not fail if there was already a version published. Drone by default does not do tag builds so it was expected that most users would just put it in their pipelines which would build on all branches.

If you enable tags you can have it only attempt to push on a tagged build.

But yea I can probably make the logging clearer.

brenwell commented 6 years ago

I understand, thanks @donny-dont

donny-dont commented 6 years ago

@brenwell did https://github.com/drone-plugins/drone-npm/pull/35 solve this for you?

brenwell commented 6 years ago

looks good, thanks!

tboerger commented 6 years ago

So let's close this as it seems to be resolved.