Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot publish npm package from release-it #697

Closed
magicaltoast opened this issue Aug 31, 2020 · 24 comments
Closed

Cannot publish npm package from release-it #697

magicaltoast opened this issue Aug 31, 2020 · 24 comments

Comments

@magicaltoast
Copy link

Hi, when I try to manually publish the npm package everything works fine.
But when I execute the release-it command I get the following error:

ERROR Unable to reach npm registry (timed out after 10000ms).

release-it --dry-run give my this

release-it --dry-run
! npm ping
! npm whoami
$ npm show instancequeue@latest version
WARNING No version found in npm registry. Assuming new package.
$ git diff --quiet HEAD
$ git rev-parse --abbrev-ref HEAD
$ git config --get branch.master.remote
$ git remote get-url origin
! git fetch
$ git describe --tags --abbrev=0
$ git symbolic-ref HEAD
$ git for-each-ref --format="%(upstream:short)" refs/heads/master
! git log --pretty=format:"* %s (%h)"

🚀 Let's release instancequeue (currently at 1.1.10)


Empty changelog

? Select increment (next version): patch (1.1.11)
! npm version 1.1.11 --no-git-tag-version
$ git status --short --untracked-files=no

Empty changeset

!
? Commit (Release 1.1.11)? Yes
!
? Tag (1.1.11)? Yes
!
? Push? Yes
$ git symbolic-ref HEAD [cached]
$ git for-each-ref --format="%(upstream:short)" refs/heads/master [cached]
!
? Publish instancequeue to npm? Yes
$ npm publish . --tag latest   --dry-run
ERROR Error
    at /usr/local/lib/node_modules/release-it/lib/shell.js:67:18
    at /usr/local/lib/node_modules/release-it/node_modules/shelljs/src/exec.js:127:9
    at ChildProcess.exithandler (child_process.js:315:5)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1047:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
Rolling back changes...
! git tag --delete 1.1.11
! git reset --hard HEAD~1
@webpro
Copy link
Collaborator

webpro commented Sep 2, 2020

Not sure why it fails. Could you please try with DEBUG=release-it:* release-it [...] and see what error output npm (or release-it) reports?

@nurikk
Copy link

nurikk commented Sep 2, 2020

Same issue is here, release-it stopped updating package version in latest update

@nurikk
Copy link

nurikk commented Sep 2, 2020

Use --no-npm(or"npm": false) to ignore and skip bumping package.jsonand skipnpm publish altogether.

Perhaps this option breaks release. I use "npm": false to bump tags, push to git, and then travis does build and publishes.
Since disabling npm disables package.json bump is causing this problem

@webpro
Copy link
Collaborator

webpro commented Sep 3, 2020

@nurikk You are referring to the difference between { npm: false } and { npm: { publish: false } }. I can see from the output in the OP that @magicaltoast does not have configuration like this.

@webpro
Copy link
Collaborator

webpro commented Sep 3, 2020

By the way, from the output I saw there was a bug in the dry-run (some lines are basically empty), I've fixed that in the latest release.

@magicaltoast
Copy link
Author

@webpro here is the result with debug output

(base) idk@idk-Latitude-E6430:~/projects/graph-from-reddit$ DEBUG=release-it:* release-it
  release-it:config { cosmiconfig: null } +0ms
  release-it:config {
  release-it:config   system: { 'release-it': '13.7.0', node: 'v14.9.0', os: 'Linux 5.4' }
  release-it:config } +13ms
  release-it:config {
  release-it:config   _: [],
  release-it:config   increment: undefined,
  release-it:config   ci: undefined,
  release-it:config   hooks: {},
  release-it:config   git: {
  release-it:config     changelog: 'git log --pretty=format:"* +1ms (%h)" ${from}...${to}',
  release-it:config     requireCleanWorkingDir: true,
  release-it:config     requireBranch: false,
  release-it:config     requireUpstream: true,
  release-it:config     requireCommits: false,
  release-it:config     addUntrackedFiles: false,
  release-it:config     commit: true,
  release-it:config     commitMessage: 'Release ${version}',
  release-it:config     commitArgs: [],
  release-it:config     tag: true,
  release-it:config     tagName: null,
  release-it:config     tagAnnotation: 'Release ${version}',
  release-it:config     tagArgs: [],
  release-it:config     push: true,
  release-it:config     pushArgs: [ '--follow-tags' ],
  release-it:config     pushRepo: ''
  release-it:config   },
  release-it:config   npm: {
  release-it:config     publish: true,
  release-it:config     publishPath: '.',
  release-it:config     tag: null,
  release-it:config     otp: null,
  release-it:config     ignoreVersion: false,
  release-it:config     skipChecks: false,
  release-it:config     timeout: 10
  release-it:config   },
  release-it:config   github: {
  release-it:config     release: false,
  release-it:config     releaseName: 'Release ${version}',
  release-it:config     releaseNotes: null,
  release-it:config     preRelease: false,
  release-it:config     draft: false,
  release-it:config     tokenRef: 'GITHUB_TOKEN',
  release-it:config     assets: null,
  release-it:config     host: null,
  release-it:config     timeout: 0,
  release-it:config     proxy: null,
  release-it:config     skipChecks: false
  release-it:config   },
  release-it:config   gitlab: {
  release-it:config     release: false,
  release-it:config     releaseName: 'Release ${version}',
  release-it:config     releaseNotes: null,
  release-it:config     tokenRef: 'GITLAB_TOKEN',
  release-it:config     assets: null,
  release-it:config     origin: null,
  release-it:config     skipChecks: false
  release-it:config   },
  release-it:config   isUpdate: false,
  release-it:config   version: {
  release-it:config     increment: undefined,
  release-it:config     isPreRelease: false,
  release-it:config     preReleaseId: undefined
  release-it:config   }
  release-it:config }
  release-it:plugins {
  release-it:plugins   namespace: 'version',
  release-it:plugins   options: {
  release-it:plugins     increment: undefined,
  release-it:plugins     isPreRelease: false,
  release-it:plugins     preReleaseId: undefined
  release-it:plugins   }
  release-it:plugins } +0ms
  release-it:plugins {
  release-it:plugins   namespace: 'npm',
  release-it:plugins   options: {
  release-it:plugins     publish: true,
  release-it:plugins     publishPath: '.',
  release-it:plugins     tag: null,
  release-it:plugins     otp: null,
  release-it:plugins     ignoreVersion: false,
  release-it:plugins     skipChecks: false,
  release-it:plugins     timeout: 10
  release-it:plugins   }
  release-it:plugins } +3ms
  release-it:plugins {
  release-it:plugins   namespace: 'git',
  release-it:plugins   options: {
  release-it:plugins     changelog: 'git log --pretty=format:"* +5ms (%h)" ${from}...${to}',
  release-it:plugins     requireCleanWorkingDir: true,
  release-it:plugins     requireBranch: false,
  release-it:plugins     requireUpstream: true,
  release-it:plugins     requireCommits: false,
  release-it:plugins     addUntrackedFiles: false,
  release-it:plugins     commit: true,
  release-it:plugins     commitMessage: 'Release ${version}',
  release-it:plugins     commitArgs: [],
  release-it:plugins     tag: true,
  release-it:plugins     tagName: null,
  release-it:plugins     tagAnnotation: 'Release ${version}',
  release-it:plugins     tagArgs: [],
  release-it:plugins     push: true,
  release-it:plugins     pushArgs: [ '--follow-tags' ],
  release-it:plugins     pushRepo: '',
  release-it:plugins     isUpdate: false
  release-it:plugins   }
  release-it:plugins }
  release-it:metrics {
  release-it:metrics   url: 'http://www.google-analytics.com/collect',
  release-it:metrics   statusCode: 200,
  release-it:metrics   statusMessage: 'OK',
  release-it:metrics   payload: 'v=1&tid=UA-108828841-1&cid=15103e78-5b49-4c54-817d-da0ba88e2f63&vp=167x21&sd=1-bit&cd1=13.7.0&cd2=v14.9.0&cd3=Linux+5.4&cd4=1&cd5=0&cd6=0&cd7=0&cd8=null&cd9=undefined&cd11=0&cd12=1&cd13=1&cd14=0&cd15=undefined&cd16=0&t=event&ec=session&ea=start'
  release-it:metrics } +0ms
  release-it:shell { command: 'npm ping', options: {}, code: 243, stdout: '', stderr: '' } +0ms
  release-it:shell { command: 'npm whoami', options: {}, code: 0, stdout: '', stderr: '' } +585ms
  release-it:shell {
  release-it:shell   command: 'npm show reddit-to-graph@latest version',
  release-it:shell   options: { write: false },
  release-it:shell   code: 243,
  release-it:shell   stdout: '',
  release-it:shell   stderr: ''
  release-it:shell } +542ms
  release-it:metrics {
  release-it:metrics   url: 'http://www.google-analytics.com/collect',
  release-it:metrics   statusCode: 200,
  release-it:metrics   statusMessage: 'OK',
  release-it:metrics   payload: 't=exception&exd=Error%3A+Unable+to+reach+npm+registry+%28timed+out+after+10000ms%29.'
  release-it:metrics } +3s
ERROR Unable to reach npm registry (timed out after 10000ms).
(base) idk@idk-Latitude-E6430:~/projects/graph-from-reddit$ 

@webpro
Copy link
Collaborator

webpro commented Sep 3, 2020

@magicaltoast Maybe you're on a slow connection? Or you are using an alternative npm registry? I have no idea what code 243 means.

Anyway, you have two options:

  • Use --npm.timeout=100 to increase the timeout (in seconds, default is 10)
  • Use --npm.skipChecks to skip the ping, authentication and latest version checks altogether.

@jchamb
Copy link

jchamb commented Sep 4, 2020

@webpro Same for me as well, started about the same time (Tuesday afternoon EST) as original post. For me it appeared randomly, It was not after updating version or anything. After it started failing I tried updating to newest version with the same result.

The error message I get is slightly different:

> release-it --preRelease=next
ERROR Timed out after NaNms.
Documentation: https://git.io/release-it-npm

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @webfx/core-client@2.0.19 release-next: `release-it --preRelease=next`
npm ERR! Exit status 1

That happens basically immediately on run not waiting on the timeout time. Running with the flags doesn't change anything. Based on all the above outputs seems to be issues talking to npm so I think we are all dealing with the same problem. If I'm wrong I apologize for piling on.

I did confirm that if I manually run all the steps that release-it does and manually call npm publish it publishes without any issues.

The verbose log from the npm error file is below incase it helps. I'm not really sure what all to look for here, but im gonna play around with implementing a custom npm service copied from the built in one to see if i can figure out whats going on.

Thanks!

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'release-next',
1 verbose cli   '--dry-run',
1 verbose cli   '--npm.skipChecks'
1 verbose cli ]
2 info using npm@6.14.8
3 info using node@v14.3.0
4 verbose run-script [ 'prerelease-next', 'release-next', 'postrelease-next' ]
5 info lifecycle @webfx/core-client@2.0.19~prerelease-next: @webfx/core-client@2.0.19
6 info lifecycle @webfx/core-client@2.0.19~release-next: @webfx/core-client@2.0.19
7 verbose lifecycle @webfx/core-client@2.0.19~release-next: unsafe-perm in lifecycle true
8 verbose lifecycle @webfx/core-client@2.0.19~release-next: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/jakechamberlain/Sites/core-client/node_modules/.bin:/Users/jakechamberlain/.yarn/bin:/Users/jakechamberlain/.config/yarn/global/node_modules/.bin:/Users/jakechamberlain/.pyenv/shims:/Users/jakechamberlain/google-cloud-sdk/bin:/Users/jakechamberlain/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/jakechamberlain/.rvm/bin
9 verbose lifecycle @webfx/core-client@2.0.19~release-next: CWD: /Users/jakechamberlain/Sites/core-client
10 silly lifecycle @webfx/core-client@2.0.19~release-next: Args: [ '-c', 'release-it --preRelease=next' ]
11 silly lifecycle @webfx/core-client@2.0.19~release-next: Returned: code: 1  signal: null
12 info lifecycle @webfx/core-client@2.0.19~release-next: Failed to exec release-next script
13 verbose stack Error: @webfx/core-client@2.0.19 release-next: `release-it --preRelease=next`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1051:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid @webfx/core-client@2.0.19
15 verbose cwd /Users/jakechamberlain/Sites/core-client
16 verbose Darwin 19.5.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "release-next" "--dry-run" "--npm.skipChecks"
18 verbose node v14.3.0
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error @webfx/core-client@2.0.19 release-next: `release-it --preRelease=next`
22 error Exit status 1
23 error Failed at the @webfx/core-client@2.0.19 release-next script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@webpro
Copy link
Collaborator

webpro commented Sep 4, 2020

@jchamb probably you somehow have npm.timeout to be undefined. The default value is 10 (seconds).

Just for the record, with npm.skipChecks enabled, there's really no request to npm and no timer running (whether it's a dry run or not):

const timeout = Number(this.options.timeout) * 1000;
if (publish === false || isPrivate) return;
if (skipChecks) return;
const validations = Promise.all([this.isRegistryUp(), this.isAuthenticated(), this.getLatestRegistryVersion()]);
await Promise.race([validations, rejectAfter(timeout, e(`Timed out after ${timeout}ms.`, docs))]);
const [isRegistryUp, isAuthenticated, latestVersionInRegistry] = await validations;
if (!isRegistryUp) {
throw e(`Unable to reach npm registry (timed out after ${timeout}ms).`, docs);
}
if (!isAuthenticated) {
throw e('Not authenticated with npm. Please `npm login` and try again.', docs);
}

@artemtam
Copy link

artemtam commented Sep 7, 2020

I face a similar issue using a private npm registry. It says ERROR User<username> is not a collaborator for <@scope/package-name>.

Adding --npm.skipChecks flag fixes it; however, it makes sense to check if the package is going to be published to the custom npm registry (it is set in publishConfig) and skip them automatically.

@webpro
Copy link
Collaborator

webpro commented Sep 7, 2020

@artemtam This is a different issue, could you please open a new ticket for this? Thanks a lot.

@jchamb
Copy link

jchamb commented Sep 9, 2020

@webpro Just an update on my issue, you were correct that issue was purely the timeout option being undefined. My setup has a custom plugin setup that I extend off the npm plugin. Previously I was just adding a beforeRelease method to handle some build logic variances based off the tag. I had to add in an override of getInitialOptions to get it to read in the default npm configuration correctly now. Once I fixed that everything started working again. Thanks for pointing me in the right direction.

@markcellus
Copy link

This is possibly related to #637. I only seem to run into this issue when using release-it against a private npm registry (we're using artifactory).

@webpro
Copy link
Collaborator

webpro commented Oct 11, 2020

@mkay581 Any chance you could reproduce the error with a DEBUG:release-it:* release-it [...] run? Any interesting output related to either npm errors or Artifactory response?

@busyhe
Copy link

busyhe commented Nov 11, 2020

image
same problem

@stale
Copy link

stale bot commented Jan 10, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Jan 10, 2021
@dcharbonnier
Copy link

the issue is an issue of npm in recent versions, the workaround for now is to use npm publish --registry=xxx as npm does not use
correctly publishConfig it would be nice to be able to set this option in release-it

@stale stale bot removed the wontfix label Jan 11, 2021
@dcharbonnier
Copy link

a dirty hack that works :

npm:
  publishPath: "--registry=xxxxx"

!! this is not the purpose of publishPath but as there is no check you can inject anything you want on the publish command

kfinn added a commit to kfinn/react-native-twilio-video that referenced this issue Jan 13, 2021
@stale
Copy link

stale bot commented Mar 16, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Mar 16, 2021
@dcharbonnier
Copy link

As mentioned in this comment i think a publishOptions could be useful

npm:
  publishPath: "--registry=xxxxx"

!! this is not the purpose of publishPath but as there is no check you can inject anything you want on the publish command

@stale stale bot removed the wontfix label Mar 16, 2021
@webpro
Copy link
Collaborator

webpro commented Mar 16, 2021

Thanks @dcharbonnier. Do you know of any resources that mention this? I.e. which version(s) of npm have this issue and/or in what circumstances? If I understand correctly, the npm publish command ignores the publishConfig.registry in package.json, and requires the --registry argument explicitly.

@webpro
Copy link
Collaborator

webpro commented Mar 20, 2021

I added the npm.publishArgs option in v14.5.0 so you can do something like this to work around the issue:

release-it --npm.publishArgs="--registry=https://registry.npmjs.org"

@markcellus
Copy link

markcellus commented Mar 20, 2021

@webpro I believe @dcharbonnier may have been referencing npm/cli#2525: a bug in npm where publishConfig.registry was not being detected correctly when publishing. The issue has since been fixed. But if anyone is using the npm version with that bug, they'd need to explicitly set the publishPath via command line arg, which you're now supporting. Hope this helps!

@webpro
Copy link
Collaborator

webpro commented Mar 20, 2021

Great - thanks for clarifying this, @markcellus!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants