Getting 404 when attempting to publish new package

2019-05-07 15:21发布

问题:

I just created a new package: https://github.com/supericium/pli

I'm now trying to publish it to NPM for the first time like this:

    ole@MKI:~/Sandbox/pli$ npm publish  --access public
    npm ERR! publish Failed PUT 404
    npm ERR! Linux 3.13.0-93-generic
    npm ERR! argv "/home/ole/.nvm/versions/v6.4.0/bin/node" "/home/ole/.nvm/versions/v6.4.0/bin/npm" "publish" "--access" "public"
    npm ERR! node v6.4.0
    npm ERR! npm  v3.10.3
    npm ERR! code E404

    npm ERR! 404 Not found : @supericium/pli
    npm ERR! 404 
    npm ERR! 404  '@supericium/pli' is not in the npm registry.
    npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
    npm ERR! 404 
    npm ERR! 404 Note that you can also install from a
    npm ERR! 404 tarball, folder, http url, or git url.

    npm ERR! Please include the following file with any support request:
    npm ERR!     /home/ole/Sandbox/pli/npm-debug.log

I tried updating both NodeJS and NPM to make sure that I have the latest version, which are:

ole@MKI:~/Sandbox/pli$ node --version
v6.4.0
ole@MKI:~/Sandbox/pli$ npm --version
3.10.3

Thoughts?

TIA, Ole

回答1:

You need to have registered "supericium" (npm adduser) as a username at the registry and be logged in to publish under that scope.

  • https://docs.npmjs.com/getting-started/publishing-npm-packages
  • https://docs.npmjs.com/getting-started/scoped-packages


回答2:

Came across this same error, and my issue was that the package was somehow set to "Read" access only. So I have to go to the NPM and update the package to "Read/Write" access:

1.

2.



回答3:

in my case i noticed that my npm account username in npm website is different than my npm normal user name. When i try to publish in console by login with normal username gave me this error.

publish Failed PUT 404 npm ERR! code E404 npm ERR! 404 User not found

But after login to console with account name it has published successfully



回答4:

Once you successfully publish the package you may experience when you try to npm install:

npm ERR! code E404
npm ERR! 404 Not Found: @xxx/yyy@latest

or something similar, regardless if you npm publish was successful. In this case make sure your {main: 'file.js'} in packages.json is there.

Ideally, you can call it index.js if you wish to leech directly from the package so you don't get things like import * from '@xxx/yyy/file'.