-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
Fix npm access error(#665) #666
Conversation
You have a typo. Should be: const args = ['access', 'list', 'collaborators', packageName]; |
|
Thank you for your feedback! TimeoutError {
context: {},
message: 'Connection to npm registry timed out',
} |
So, I now committed the changes to the test files as well and now the Github Actions tests run without error on my forked repo 👍 |
source/npm/util.js
Outdated
@@ -68,7 +68,7 @@ exports.collaborators = async pkg => { | |||
const packageName = pkg.name; | |||
ow(packageName, ow.string); | |||
|
|||
const args = ['access', 'ls-collaborators', packageName]; | |||
const args = ['access', 'list', 'collaborators', packageName]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a --json
as well
Hey @DerTimonius, looks like you're pretty close. Anything I can do to help? |
Hey @schuchard , thank you for your offer! |
Hi @sindresorhus, is there anything else needed to merge this PR? Thanks. |
I don't know why the tests are failing now with an error message that should be solved ( |
Maybe it's failing on an older version of Maybe it should be conditional on what version of |
Seems likely. NPM 9 brought a breaking change to npm access:
If this package intends to support npm < 9, conditional logic and tests are needed. |
I'm making progress: I implemented a Currently I have one failing test left: prerequisite-tasks › should fail when user is not authenticated at external registry
142: await t.throwsAsync(run(testedModule('2.0.0', {name: 'test', version:…
143: {message: 'You do not have write permissions required to publish th…
Promise resolved with:
undefined Locally, I always get a Timeout Error on this test though... |
Any hints on what I'm missing? |
So this is the error message that you're getting:
This indicates that the collaborators JSON here actually passed the test: np/source/prerequisite-tasks.js Lines 44 to 48 in 95622c0
You could try logging out this value to see if this is truly the case. Or, second idea: maybe the check for Lines 11 to 14 in 6d4f036
To me |
Last tip, the order of your arguments in these three places is different: Line 73 in 6d4f036
Line 119 in 6d4f036
Line 139 in 6d4f036
|
Thank you for your inputs @karlhorky ! After logging out a few things, I narrowed the problem down to an issue with the external registry:
try {
const {stdout} = await execa('npm', args);
return stdout;
} catch (error) {
// Ignore non-existing package error
if (error.stderr.includes('code E404')) {
return false;
}
throw error;
} So, logging out the error here gives me this message:
But the command is this:
I don't know where the Regarding this:
You're right, I tried to do is as an array in the first place, but wasn't able to for some reason. Put it inside the test now, just to be sure. |
So, I removed the conditional arguments in the tests since it does not have any effect on the executed code, now it's again this
instead of:
I suspected that maybe this change could be the reason the tests are failing. |
Hey @sindresorhus, is there anything else I have to change? |
Thank you for considering this PR
This is my first contribution to open source, so if this PR description is a bit too much, please let me know 😃This PR fixes the
npm access
error that occurs after updating npm to version 9.0.0.According to the npm documentation the
npm access
subcommands have been changed fromls-collaborators
tolist collaborators
.Switching
to
did not work, it keeps failing with the same errors.
Changing the execa arguments (on line 77) from
npm
tonpm access list collaborators
while stripping theargs
variable eliminated the error.Fixes #665