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

Yarn: np hangs when installed as a local devDependency #592

Closed
mshwery opened this issue Jan 15, 2021 · 5 comments
Closed

Yarn: np hangs when installed as a local devDependency #592

mshwery opened this issue Jan 15, 2021 · 5 comments
Labels

Comments

@mshwery
Copy link

mshwery commented Jan 15, 2021

np@7.2.0 seems to hang when run as a local devDependency.

Description

I've installed np@7.2.0 as a local devDependency.: yarn add -D np. When running yarn np (with or without flags or arguments) it hangs. After minutes of waiting I have to manually terminate it.

If I instead yarn remove np and then use npx np (same version of np) it starts immediately.

Steps to reproduce

  1. yarn add -D np@7.2.0
  2. yarn np
  3. Process hangs

Expected behavior

I expect that running the local version of np should work immediately, like the global or npx way.

Environment

np - 7.2.0
Node.js - 12.18.0
npm - 6.14.4
Git - git version 2.24.3 (Apple Git-128)
OS - macOS Catalina 10.15.7
yarn - 1.22.10

@cdimitroulas
Copy link

I thought I had the same problem on 7.4.0 but after waiting a while it finally started the publishing process

@fregante fregante added the bug label Feb 3, 2023
@fregante fregante changed the title np hangs when installed as a local devDependency np hangs when installed as a local devDependency with Yarn Feb 3, 2023
@fregante fregante changed the title np hangs when installed as a local devDependency with Yarn Yarn: np hangs when installed as a local devDependency Feb 3, 2023
@earonesty
Copy link

earonesty commented Jun 14, 2023

i've seen it hang if isPackageNameAvailable never returns. the culprit is the is-name-taken npm, which ships a massive uncompressed json file of packages every once in a while. if it's a few months out of date... it starts to get very slow at npmjs.

@slhck
Copy link
Contributor

slhck commented Jul 26, 2023

I can confirm this is the culprit. It's waiting to check if a package is available. I replaced the code in node_modules/np/source/cli-implementation.js:

	const availability = flags.publish ? await npm.isPackageNameAvailable(pkg) : {
		isAvailable: false,
		isUnknown: false,
	};

With:

const availability = {
  isAvailable: true,
  isUnknown: false,
}

In my case it's possibly linked to the registry being a private one (using Verdaccio). I realize these may not be supported. But this did work in earlier versions of np — maybe there was a recent change there.

@earonesty
Copy link

i worked with the dev to fix the upstream issue. should hang less often, but still relies on network connection

@slhck
Copy link
Contributor

slhck commented Jul 27, 2023

I suggest adding a timeout there (e.g. reusing the pTimeout function) just to make sure.

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

No branches or pull requests

5 participants