I have a problem publishing scoped npm-packages to a private nexus-repo.
The name of the package is @spike/core. The error message is:
npm notice Publishing to https://nexus.pitsfs.work/repository/npm-releases/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://nexus.pitsfs.work/repository/npm-releases/@spike%2fcore
npm ERR! 404
npm ERR! 404 '@spike/core@5.4.3' is not in this registry.
Environment:
- Nexus-Version: 3.57.0-01
- node-Version: 16.18.1
- npm-Version: 8.19.2
- Client Operating-System: Windows 10
It seems to be a problem with the escaped name of @spike/core (escaped to @spike%2fcore). To verify this, I've made the following change to the file c:\Program Files\nodejs\node_modules\npm\node_modules\libnpmpublish\lib\publish.js (which is executed, when npm publish
is called):
...
if (!spec.scope && opts.access === 'restricted') {
throw Object.assign(
new Error("Can't restrict access to unscoped packages."),
{ code: 'EUNSCOPED' }
)
}
// ***************************************************************************
// !!! This added line fixed the problem (npm publish worked fine with it) !!!
// ***************************************************************************
spec.escapedName = spec.escapedName.replace("%2f", "/");
const metadata = buildMetadata(reg, pubManifest, tarballData, opts)
try {
return await npmFetch(spec.escapedName, {
...opts,
method: 'PUT',
body: metadata,
ignoreBody: true,
})
} catch (err) {
...
Is there any configuration setting (in npm or nexus) to fix this without patching the file publish.js? I couldn't find anything in the nexus-documentation at https://help.sonatype.com/repomanager2/node-packaged-modules-and-npm-registries)