问题
I want to publish my package to npm. the error I get is: Package name too similar to existing packages
403 Forbidden - PUT https://registry.npmjs.org/mypack.... - Package name too similar to existing packages; try renaming your package to '@user../mypackage...' and publishing with 'npm publish --access=public' instead
but when I try to install:
npm I mypackage...
I get the error not found:
npm ERR! 404 Not Found - GET https://registry.npmjs.org/mypackage... - Not found
Is there a way to check if the name is good for npm and not just guess? because I can't delete the package after I publish..
回答1:
To check similar names you can use validate-name:
Install:
$ npm install -g validate-name
Use:
$ validate-npm-name my-module
$ validate-npm-name my-package --max-age 1440
What it does:
This command checks whether similar names exist in npm registry.
Upon first use, it downloads full list of module names (apprx. 150MB as of this writing) to check similarity. Subsequent downloads are much smaller, because it only downloads updates since last download.
I created this module by following script suggested by @RobC in OP's comments. It is open source (MIT).
As described in the original script, it is a best effort, because similarity rules are not formally documented by npm.
来源:https://stackoverflow.com/questions/60665491/npm-publish-got-package-name-too-similar-to-existing-packages