Fix npm access error(#665)#666
Fix npm access error(#665)#666sindresorhus merged 18 commits intosindresorhus:mainfrom DerTimonius:main
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 👍 |
| ow(packageName, ow.string); | ||
|
|
||
| const args = ['access', 'ls-collaborators', packageName]; | ||
| const args = ['access', 'list', 'collaborators', packageName]; |
|
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:
undefinedLocally, 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 |
|
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 accesserror that occurs after updating npm to version 9.0.0.According to the npm documentation the
npm accesssubcommands have been changed fromls-collaboratorstolist collaborators.Switching
to
did not work, it keeps failing with the same errors.
Changing the execa arguments (on line 77) from
npmtonpm access list collaboratorswhile stripping theargsvariable eliminated the error.Fixes #665