Npm publish is failing with 400 Bad Request - npm

I am trying to publish #babel/runtime package into my gitlab registry and while doing so i am facing E400 error. Adding the error logs below
npm notice === Tarball Details ===
npm notice name: #babel/runtime
npm notice version: 7.18.9
npm notice package size: 30.2 kB
npm notice unpacked size: 202.4 kB
npm notice shasum: dd63a562109741efdb37bd99af6873c143ea4f92
npm notice integrity: sha512-V6s46s886z0JV[...]zG4PMb7qvVVSA==
npm notice total files: 193
npm notice
npm ERR! code E400
npm ERR! 400 Bad Request - PUT https://gitlab.server.net/api/v4/projects/69/packages/npm/#babel%2fruntime
npm ERR! A complete log of this run can be found in:
npm ERR! /home/gitlab/.npm/_logs/2022-08-29T11_16_10_937Z-debug.log
adding the details of npmrc below
//gitlab.server.net/api/v4/projects/69/packages/npm/:_authToken={AUTH_TOKEN}
registry=https://gitlab.server.net/api/v4/projects/69/packages/npm/

Almost certainly you're violating the package naming guidelines - unless your group name is #babel.

Related

NPM attempts to publish twice

I am maintaining my first npm package so this might be an error on my part. Once build my package and commit it to git the next step is:
$ npm version patch
$ npm publish
The output (abridged) is as follows:
npm notice
npm notice 📦 #mememe/p3-model#0.7.2
npm notice === Tarball Contents ===
npm notice 188B README.md
npm notice 4.5kB dist/doc.d.ts
(etc)
npm notice 792B package.json
npm notice === Tarball Details ===
npm notice name: #mememe/p3-model
npm notice version: 0.7.2
npm notice filename: #mememe/p3-model-0.7.2.tgz
npm notice package size: 6.2 kB
npm notice unpacked size: 23.2 kB
npm notice shasum: cb5588ee626efc21532845c608fdb05a5fcd4db3
npm notice integrity: sha512-s7IK2HSXCNTUk[...]ZHxDgAOIr4Cnw==
npm notice total files: 11
npm notice
npm notice Publishing to https://registry.npmjs.org/
⸨⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠇ : notice Publishing to https://registry.npmjs.org/
So far so good. But then somehow it attempts to publish again and gets an error that I am publishing on top of an old version. The output continues:
> #mememe/p3-model#0.7.2 publish
> npm publish
npm notice ⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠇ : notice Publishing to https://registry.npmjs.org/
npm notice 📦 #mememe/p3-model#0.7.2
npm notice === Tarball Contents ===
npm notice 188B README.md
npm notice 4.5kB dist/doc.d.ts
npm notice 6.5kB dist/doc.js
(etc)
npm notice === Tarball Details ===
npm notice name: #mememe/p3-model
npm notice version: 0.7.2
npm notice filename: #mememe/p3-model-0.7.2.tgz
npm notice package size: 6.2 kB
npm notice unpacked size: 23.2 kB
npm notice shasum: cb5588ee626efc21532845c608fdb05a5fcd4db3
npm notice integrity: sha512-s7IK2HSXCNTUk[...]ZHxDgAOIr4Cnw==
npm notice total files: 11
npm notice
npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/#mememe%2fp3-model - You cannot publish over the previously published versions: 0.7.2.
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.
⸨⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠇ : notice Publishing to https://registry.npmjs.org/
npm ERR! A complete log of this run can be found in:
I only entered the npm publish command once. Is there some action of this command (perhaps an option in package.json) that would cause this?
The correct package gets published and I can use it in other projects. But this error is a bit disconcerting. Any suggestions?
I had the same issue and just solved it.
My problem was, that i had defined a script with publish in my package.json, so it was fired after/before again.
The idea behind that was to have a hint (like a command list) about the commands i use for building, testing, generating documentation and publishing. But unfortunately then the command was fired twice all the time.
In my case, the package.json looked like this:
{
"name": "my-package",
"version": "1.0.0",
"scripts": {
"build": "echo here could be a build job",
"test": "jasmine",
"publish": "npm publish"
}
Check your package.json for a entry at scripts which key is named publish. If you have an entry with the key publish, then remove this line entirely or use a different key for your script.

Can not "npm publish" to internally-hosted npm repository?

I followed Using Nexus 3 as Your Repository – Part 2: npm Packages to set up an internal npm repository.
I'm then able to do this,
$ npm view jsreport dist.tarball
https://registry.npmjs.org/jsreport/-/jsreport-3.0.1.tgz
I have this in my ~/.npmrc file
$ cat ~/.npmrc
//internal_nexus_url:8081/repository/:_authToken=NpmToken.43b77b61-2492-39b8-8150-38555f6b6943
I have this in my /path_to_project/.npmrc file
registry="http://internal_nexus_url:8081/repository/npm-private/_auth=base64_user_pw"
and this in my /path_to_project/package.json file
{
...
"publishConfig": {
"registry": "http://internal_nexus_url:8081/repository/npm-private"
},
...
}
When do an npm publish I get
npm notice === Tarball Details ===
npm notice name: my-package
npm notice version: 2.4.4
npm notice filename: my-package-2.4.4.tgz
npm notice package size: 141.6 MB
npm notice unpacked size: 421.1 MB
npm notice shasum: 09c134ef93ce70e999d62820b5bffc6cf23765f3
npm notice integrity: sha512-X5iqe9DV03MPG[...]TKvNZO4O8ToyQ==
npm notice total files: 17559
npm notice
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in.
npm ERR! need auth You need to authorize this machine using `npm adduser`
npm ERR! A complete log of this run can be found in:
npm ERR! /patch/.npm/_logs/2021-11-16T21_48_03_450Z-debug.log
The error file above basically says the same thing. So I follow the instructions, and do
$ npm adduser
$ npm adduser
npm notice Log in on http://internal_nexus_url:8081/repository/exa-npm-private/_auth=base64_user_pw
Username: nexus-user
Password:
Email: (this IS public) nexus#kmha.com
npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
npm ERR! A complete log of this run can be found in:
npm ERR! /path/.npm/_logs/2021-11-16T21_52_29_060Z-debug.log
What's preventing me from publishing to my internal npm repo?
UPDATE:
I modified my ~/.npmrc file to include the information on How should I set _auth in .npmrc when using a Nexus https npm registry proxy? to no avail.

how to solve error code 1 when running npm

I am using Visual Studio Code on MacOS latest version.
I am getting many errors when I try to run npm start that I have posted in a separate question here:
unable to solve error code 1 when running"npm install"
I thought to install all possible modules again to solve the issue when I try to run:
npm i -g npm
I even get errors that part of that is copied here:
ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /usr/local/lib/node_modules/node/bin/node
/usr/local/lib/node_modules/npm/bin/npm-cli.js install --force --
cache=/Users/afshinshahpari/.npm --prefer-offline=false --prefer-online=false --
offline=false --no-progress --no-save --no-audit --include=dev --include=peer --
include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN old lockfile
npm ERR! npm WARN old lockfile The package-lock.json file was created with an old
version of npm,
npm ERR! npm WARN old lockfile so supplemental metadata must be fetched from the
registry.
npm ERR! npm WARN old lockfile
npm ERR! npm WARN old lockfile This is a one-time fix-up, please be patient...
npm ERR! npm WARN old lockfile
npm ERR! npm WARN deprecated fsevents#1.2.11: fsevents 1 will break on node v14+ and
could be using insecure binaries. Upgrade to fsevents 2.
I tried to fix the issue using this article:
npm ERR! git dep preparation failed when trying to install package.json
but when running "npm audit fix" i get a new set of errors:
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/afshinshahpari/.npm/_logs/2021-08-16T12_46_15_639Z-debug.log
in order to solve it, I used
npm i --package-lock-only
but no success.
Here's the solution bro try this.
Step 1:
$ npm cache clean --force
Step 2
Delete node_modules by
$ rm -rf node_modules package-lock.json folder
or delete it manually by going into the directory and right-click > delete / move to trash. Also, delete package-lock.json file too.
Step 3
npm install
To start again,
$ npm start
This worked for me. Hopes it works for you too.
PS: If it is still there, kindly check the error it is displaying in red and act accordingly. This error is specific to Node.js environment.

npm WARN tarball tarball data for jqwidgets-framework#8.1.4 seems to be corrupted. Trying one more time

I am getting intermittent issue during installing jqwidgets. Most of the time things working as expected but sometime I got below error
npm WARN notice [SECURITY] minimatch has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=minimatch&version=2.0.10 - Run `npm i npm#latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN tarball tarball data for jqwidgets-framework#8.1.4 (sha512-9jOhaB4hQ59pRRBk90EbzmGeEXHsBaZ+XIT2/+6Ulls4btDY6nFO31FFR7CNseWeNnqn22qQUkZcfnj084FrsQ==) seems to be corrupted. Trying one more time.
Cannot contact dcs-jenkins-s13: java.lang.InterruptedException
npm WARN The package #types/node is included as both a dev and production dependency.
npm ERR! path /mnt/nfs_jenkins/dcs-jenkins-s13/workspace/d_MyProject/node_modules/.staging/jqwidgets-framework-f4ca9813/jqwidgets-ng/dist/esm2015/jqxnavigationbar/.nfs0000000002d7d99900003970
npm ERR! code EBUSY
npm ERR! errno -16
npm ERR! syscall unlink
npm ERR! EBUSY: resource busy or locked, unlink '/mnt/nfs_jenkins/dcs-jenkins-s13/workspace/myproject/node_modules/.staging/jqwidgets-framework-f4ca9813/jqwidgets-ng/dist/esm2015/jqxnavigationbar/.nfs0000000002d7d99900003970'

npm install package.js - can I revert to earlier package?

I am following this tutorial on vue.js on YouTube. One of the packages I installed was eslint 5.5 (which is the current version). I saw this error message:
npm ERR! Failed at the server#1.0.0 lint script 'eslint **/*.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! eslint **/*.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs server
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls server
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/jason/Documents/vue-movie/server/npm-debug.log
I tried updating Node and NPM, but that did not change this failure. The tutorial is using "^4.6" and I was wondering if there is a way to revert the package I have to an earlier version? And how would I do that?