Getting Bad Request (Http 400) when using npm dist-tag with Nexus 3.19.1-01 - npm

We are running Nexus OSS 3.19.1-01 (CentOS7 with OpenJdk 1.8.0_222-b10) with npm repository. Everything works fine except the npm dist-tag feature which should now work with version >3.19.
$ npm publish <pkg> --tag bla #--> works
$ npm install <pkg>#bla #--> works
$ npm dist-tag ls <pkg> #--> works
$ npm dist-tag rm --verbose #myscope/mypackage foo
npm info it worked if it ends with ok
npm verb cli [
npm verb cli '/usr/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'dist-tag',
npm verb cli 'rm',
npm verb cli '--verbose',
npm verb cli '#myscope/mypackage',
npm verb cli 'foo'
npm verb cli ]
npm info using npm#6.13.1
npm info using node#v12.13.0
npm verb npm-session 3b193197390df1cf
npm verb dist-tag del snapshot from #myscope/mypackage
npm http fetch GET 200 https://nexus.example.com/repository/npm-group/-/package/#myscope%2fmypackage/dist-tags 1396ms
npm http fetch DELETE 400 https://nexus.example.com/repository/npm-group/-/package/#myscope%2fmypackage/dist-tags/foo 9ms
npm verb stack Error: 400 Bad Request - DELETE https://nexus.example.com/repository/npm-group/-/package/#myscope%2fmypackage/dist-tags/foo
npm verb stack at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:104:15
npm verb stack at processTicksAndRejections (internal/process/task_queues.js:93:5)
npm verb statusCode 400
npm verb pkgid #myscope/mypackage#latest
npm verb cwd /home/myname/path-to-code/mypackage/client
npm verb Linux 5.3.11-300.fc31.x86_64
npm verb argv "/usr/bin/node" "/usr/local/bin/npm" "dist-tag" "rm" "--verbose" "#myscope/mypackage" "foo"
npm verb node v12.13.0
npm verb npm v6.13.1
npm ERR! code E400
npm ERR! 400 Bad Request - DELETE https://nexus.example.com/repository/npm-group/-/package/#myscope%2fmypackage/dist-tags/foo
npm verb exit [ 1, true ]
npm timing npm Completed in 1730ms
npm ERR! A complete log of this run can be found in:
npm ERR! /home/myname/.npm/_logs/2019-11-20T13_02_41_234Z-debug.log
$ npm dist-tag add #myscope/mypackage#0.1.0 bar
# did not work, same error as above
No additional log messages in nexus log.
Any idea?

I'm afraid it won't work for you, because you're running your commands against npm group repository. Both npm dist-tag add and npm dist-tag rm work only for hosted repositories as of NXRM 3.19.1. However, npm dist-tag ls is supported by all types of repositories (since 3.19.0).

Related

CodeBuild failing to run CDK synth

I'm having a problem running cdk synth on codebuild, it just says: You are not authorized to perform this operation.
It's a CDK application to provision some infrastructure using #aws-cdk/app-delivery dependency to create the CI/CD pipeline. The codebuild image I'm using is: aws/codebuild/nodejs:10.1.0
The buildspec.yml is a standard one that app-delivery shares in their readme, just adding --loglevel verbose to have a better understanding of what's happenning
phases:
install:
commands:
# Installs the npm dependencies as defined by the `package.json` file
# present in the root directory of the package
# (`cdk init app --language=typescript` would have created one for you)
- npm install
build:
commands:
# Builds the CDK App so it can be synthesized
- npm run build
# Synthesizes the CDK App and puts the resulting artifacts into `dist`
- npm run cdk synth --loglevel verbose -- -o dist
artifacts:
# The output artifact is all the files in the `dist` directory
base-directory: dist
files: '**/*'
And here are the codebuild logs:
[Container] 2019/06/06 19:20:11 Running command npm run cdk synth --loglevel verbose -- -o dist
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'run',
npm verb cli 'cdk',
npm verb cli 'synth',
npm verb cli '--loglevel',
npm verb cli 'verbose',
npm verb cli '--',
npm verb cli '-o',
npm verb cli 'dist' ]
npm info using npm#5.6.0
npm info using node#v10.1.0
npm verb run-script [ 'precdk', 'cdk', 'postcdk' ]
npm info lifecycle dvi-infrastructure-cdk#0.1.0~precdk: dvi-infrastructure-cdk#0.1.0
npm info lifecycle dvi-infrastructure-cdk#0.1.0~cdk: dvi-infrastructure-cdk#0.1.0
> dvi-infrastructure-cdk#0.1.0 cdk /codebuild/output/src891487954/src
> cdk "synth" "-o" "dist"
You are not authorized to perform this operation.
npm verb lifecycle dvi-infrastructure-cdk#0.1.0~cdk: unsafe-perm in lifecycle true
npm verb lifecycle dvi-infrastructure-cdk#0.1.0~cdk: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/codebuild/output/src891487954/src/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
npm verb lifecycle dvi-infrastructure-cdk#0.1.0~cdk: CWD: /codebuild/output/src891487954/src
npm info lifecycle dvi-infrastructure-cdk#0.1.0~cdk: Failed to exec cdk script
npm verb stack Error: dvi-infrastructure-cdk#0.1.0 cdk: `cdk "synth" "-o" "dist"`
npm verb stack Exit status 1
npm verb stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
npm verb stack at EventEmitter.emit (events.js:182:13)
npm verb stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
npm verb stack at ChildProcess.emit (events.js:182:13)
npm verb stack at maybeClose (internal/child_process.js:957:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:246:5)
npm verb pkgid dvi-infrastructure-cdk#0.1.0
npm verb cwd /codebuild/output/src891487954/src
npm verb Linux 4.14.114-83.126.amzn1.x86_64
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "cdk" "synth" "--loglevel" "verbose" "--" "-o" "dist"
npm verb node v10.1.0
npm verb npm v5.6.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dvi-infrastructure-cdk#0.1.0 cdk: `cdk "synth" "-o" "dist"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dvi-infrastructure-cdk#0.1.0 cdk script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-06-06T19_20_13_082Z-debug.log
[Container] 2019/06/06 19:20:13 Command did not exit successfully npm run cdk synth --loglevel verbose -- -o dist exit status 1
[Container] 2019/06/06 19:20:13 Phase complete: BUILD State: FAILED
[Container] 2019/06/06 19:20:13 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm run cdk synth --loglevel verbose -- -o dist. Reason: exit status 1
I've been able to check which was the error by running npm run cdk synth -- -v -o dist command in my buildspec.yml. With that I got the following error:
Some context information is missing. Fetching...
Reading AZs for 244496089465:us-west-2
Using default AWS SDK credentials for account 244496089465
You are not authorized to perform this operation.
UnauthorizedOperation: You are not authorized to perform this operation.
at Request.extractError (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/services/ec2.js:50:35)
at Request.callListeners (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /codebuild/output/src133069252/src/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/codebuild/output/src133069252/src/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
So, by adding the following permission ec2:DescribeAvailabilityZones into the codebuild role solved my problem

Npm install : FetchError: request to http://registry.npmjs.org/... failed, reason: read ECONNRESET

Trying to install any node package using npm hangs for about 5 mins then gives a ECONNRESET network error. I have been using npm for other projects recently and it worked fine but now will not work for any project(Including clean npm init)
npm i ws
This is on a Raspberry pi 3 running on my home network with no proxy requirements. All other machines both linux and windows are working fine.
npm -v = 6.4.1
I have tried the following:
npm i ws This gives me the ECONNRESET error (See below)
Curl https://registry.npmjs.org/
& Curl https://registry.npmjs.org/ws
Both return the correct json response
Removing any proxy settings
npm config rm proxy
npm config rm https-proxy
npm config set registry http://registry.npmjs.org/
Restarting etc
Full Error log:
npm i ws --save --verbose
npm info it worked if it ends with ok
npm verb cli [ '/home/pi/.nvm/versions/node/v8.16.0/bin/node',
npm verb cli '/home/pi/.nvm/versions/node/v8.16.0/bin/npm',
npm verb cli 'i',
npm verb cli 'ws',
npm verb cli '--save',
npm verb cli '--verbose' ]
npm info using npm#6.4.1
npm info using node#v8.16.0
npm verb npm-session 0a9bedb5def7f4a1
npm timing stage:rollbackFailedOptional Completed in 6ms
npm timing stage:runTopLevelLifecycles Completed in 1146975ms
npm verb type system
npm verb stack FetchError: request to http://registry.npmjs.org/ws failed, reason: read ECONNRESET
npm verb stack at ClientRequest.req.on.err (/home/pi/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm verb stack at emitOne (events.js:116:13)
npm verb stack at ClientRequest.emit (events.js:211:7)
npm verb stack at Socket.socketErrorListener (_http_client.js:401:9)
npm verb stack at emitOne (events.js:116:13)
npm verb stack at Socket.emit (events.js:211:7)
npm verb stack at emitErrorNT (internal/streams/destroy.js:66:8)
npm verb stack at _combinedTickCallback (internal/process/next_tick.js:139:11)
npm verb stack at process._tickCallback (internal/process/next_tick.js:181:9)
npm verb cwd /home/pi/projects/picamera/node_server
npm verb Linux 4.19.37-v7+
npm verb argv "/home/pi/.nvm/versions/node/v8.16.0/bin/node" "/home/pi/.nvm/versions/node/v8.16.0/bin/npm" "i" "ws" "--save" "--verbose"
npm verb node v8.16.0
npm verb npm v6.4.1
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to http://registry.npmjs.org/ws failed, reason: read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm verb exit [ 1, true ]
npm timing npm Completed in 1148813ms
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2019-05-10T23_28_17_769Z-debug.log
First check following thing:
ping registry.npmjs.org
You will get to know the IP address from that like below:
PING registry.npmjs.org (104.16.20.35) 56(84) bytes of data.
Then
sudo vi /etc/hosts
104.16.20.35 registry.npmjs.org
Then try to do following
npm install

npm prune bad PATH? Failed to exec install script

When I run npm prune I get the following (verbose) error
npm info lifecycle elm#0.19.0-bugfix2~install: elm#0.19.0-bugfix2
> elm#0.19.0-bugfix2 install node_modules/elm
> binwrap-install
sh: 1: binwrap-install: not found
npm verb lifecycle elm#0.19.0-bugfix2~install: unsafe-perm in lifecycle true
npm verb lifecycle elm#0.19.0-bugfix2~install: PATH: /tmp/build/.heroku/node/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/tmp/build/apps/web/node_modules/elm/node_modules/.bin:/tmp/build/.heroku/node/bin:/tmp/build/.platform_tools:/tmp/build/.platform_tools/erlang/bin:/tmp/build/.platform_tools/elixir/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
npm verb lifecycle elm#0.19.0-bugfix2~install: CWD: node_modules/elm
npm info lifecycle elm#0.19.0-bugfix2~install: Failed to exec install script
npm timing action:install Completed in 79ms
npm verb unlock done using /app/.npm/_locks/staging-4628ace6b39e4e32.lock for /tmp/build/apps/web/node_modules/.staging
npm timing stage:rollbackFailedOptional Completed in 62ms
npm timing stage:runTopLevelLifecycles Completed in 6364ms
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
npm verb stack Error: elm#0.19.0-bugfix2 install: `binwrap-install`
npm verb stack spawn ENOENT
npm verb stack at ChildProcess.<anonymous> (/tmp/build/.heroku/node/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
npm verb stack at ChildProcess.emit (events.js:182:13)
npm verb stack at maybeClose (internal/child_process.js:961:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
npm verb pkgid elm#0.19.0-bugfix2
npm verb cwd /tmp/build/apps/web
npm verb Linux 4.15.0-36-generic
npm verb argv "/tmp/build/.heroku/node/bin/node" "/tmp/build/.heroku/node/bin/npm" "prune" "--verbose"
npm verb node v10.7.0
npm verb npm v6.1.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! elm#0.19.0-bugfix2 install: `binwrap-install`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the elm#0.19.0-bugfix2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 6866ms
It can't find binwrap-install and I think it's because the PATH is incorrect. I verified that the binary exists here.
ls -l node_modules/.bin/binwrap-install
lrwxrwxrwx 1 js js 30 Nov 9 23:48 node_modules/.bin/binwrap-install -> ../binwrap/bin/binwrap-install
But, the PATH in the error output above does not include
node_modules/.bin
Instead it includes
node_modules/elm/node_modules/.bin
Higher up in the verbose logging, I saw this which might be relevant.
npm info linkStuff binwrap#0.2.0
npm verb linkBins [ { 'binwrap-install': 'bin/binwrap-install',
npm verb linkBins 'binwrap-prepare': 'bin/binwrap-prepare',
npm verb linkBins 'binwrap-test': 'bin/binwrap-test' },
npm verb linkBins '/tmp/build/apps/web/node_modules/elm-format/node_modules/.bin',
npm verb linkBins false ]
npm info linkStuff fstream#0.1.31
npm info linkStuff unzip#0.1.11
npm info linkStuff binwrap#0.1.4
npm verb linkBins [ { 'binwrap-install': 'bin/binwrap-install',
npm verb linkBins 'binwrap-test': 'bin/binwrap-test' },
npm verb linkBins '/tmp/build/apps/web/node_modules/.bin',
npm verb linkBins false ]
Is this expected behavior or is it a bug somewhere? Is there something I can do to make the PATH for npm prune include the node_modules/.bin folder?
Try switching to Elm 0.19.1.
I was having this same issue and now with Elm 0.19.1 it seems to have stopped happening. The latest npm installer no longer relies on binwrap, which I think may have been the issue.
My initial command was:
$ sudo npm install elm -g
The log was:
npm ERR! elm#0.19.0-bugfix2 install: binwrap-install
I attempted to remove npm.
Then I took a drastic measure:
$ cd /usr/local/lib
$ sudo rm -R node_modules
Then:
$ sudo apt install npm
Then:
$ sudo apt install elm -g
I now have elm 0.19.0 installed.

react-native init AwesomeProject throws ETIMEDOUT error when its about to build react-native

I've been trying to init a new react-native project and always run into the same ETIMEDOUT error.
I've run "react-native init AwesomeProject --verbose" on Terminal
Here is my npm-debug.log: https://gist.github.com/danielweinmann/a3a05ec4c253b9ff0016
I've tried setting npm registry to registry.npmjs.org with both http and https on the URL.
I started testing on a Mountain Lion and then upgraded to El Capitan and continued to get the same result
It seems to install all dependencies correctly and successfuly make all afterAdd writes to package.json, but throws the error after an "unlock" verb that's executed after an "about to build".
Here's the last part of my terminal screen:
npm verb afterAdd /Users/danielweinmann/.npm/uglify-js/2.4.24/package/package.json written
npm verb about to build /Users/danielweinmann/projects/AwesomeProject/node_modules/react-native
npm verb unlock done using /Users/danielweinmann/.npm/_locks/react-native-b39cdeb3f4f93e0a.lock for /Users/danielweinmann/projects/AwesomeProject/node_modules/react-native
npm verb stack Error: connect ETIMEDOUT 23.235.46.162:443
npm verb stack at Object.exports._errnoException (util.js:856:11)
npm verb stack at exports._exceptionWithHostPort (util.js:879:20)
npm verb stack at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)
npm verb cwd /Users/danielweinmann/projects/AwesomeProject
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/Cellar/node/5.4.1/bin/node" "/usr/local/bin/npm" "install" "--verbose" "--save" "react-native"
npm ERR! node v5.4.1
npm ERR! npm v2.14.15
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect
npm ERR! network connect ETIMEDOUT 23.235.46.162:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm verb exit [ 1, true ]
npm verb unbuild node_modules/react-native
npm info preuninstall react-native#0.18.0-rc
npm info uninstall react-native#0.18.0-rc
npm verb unbuild rmStuff react-native#0.18.0-rc from /Users/danielweinmann/projects/AwesomeProject/node_modules
npm verb gentlyRm vacuuming from /Users/danielweinmann/projects/AwesomeProject/node_modules/.bin/react-native up to /Users/danielweinmann/projects/AwesomeProject
npm info postuninstall react-native#0.18.0-rc
npm verb gentlyRm don't care about contents; nuking /Users/danielweinmann/projects/AwesomeProject/node_modules/react-native
npm ERR! Please include the following file with any support request:
npm ERR! /Users/danielweinmann/projects/AwesomeProject/npm-debug.log
`npm install --save react-native` failed
Does anyone know what's happening? Can anyone help me?
Thanks a lot!
In the end, it was a network issue, indeed. I solved it by routing my mobile phone's internet connection to my computer through wi-fi.
In my case I have to disable firewall on my belkin router. Related to https://github.com/npm/npm/issues/8293 not react-native specific

Error: No compatible version found: package-json#'^6.3.0'

I want to install latest version of NPM and running this
npm install latest-version
I receive
No compatible version found:package-json'^6.3.0
npm WARN package.json copy-descriptor#0.1.1 No readme data.
npm WARN package.json get-value#2.0.6 No readme data.
npm WARN package.json object-copy#0.1.0 No readme data.
npm WARN package.json static-extend#0.1.2 No readme data.
npm http GET https://registry.npmjs.org/latest-version
npm http 200 https://registry.npmjs.org/latest-version
npm http GET https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz
npm http 200 https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz
npm http GET https://registry.npmjs.org/package-json
npm http 200 https://registry.npmjs.org/package-json
npm ERR! Error: No compatible version found: package-json#'^6.3.0'
npm ERR! Valid install targets:
npm ERR! ["0.1.0","0.2.0","1.0.0","1.0.1","1.0.2","1.1.0","1.2.0","2.0.0","2.0.1","2.1.0","2.2.0","2.2.1","2.3.0","2.3.1","2.3.2","2.3.3","2.4.0","3.0.0","3.1.0","4.0.0","4.0.1","5.0.0","6.0.0","6.1.0","6.2.0","6.3.0","6.4.0","6.5.0"]
npm ERR! at installTargetsError (C:\Program Files\nodejs\node_modules\npm\lib\cache.js:709:10)
npm ERR! at C:\Program Files\nodejs\node_modules\npm\lib\cache.js:631:10
npm ERR! at saved (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\get.js:138:7)
npm ERR! at FSReqCallback.oncomplete (fs.js:146:23)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Windows_NT 10.0.18362
npm ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "latest-version"
npm ERR! cwd C:\Users\smuminov
npm ERR! node -v v12.13.0
npm ERR! npm -v 1.2.24
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\smuminov\npm-debug.log
npm ERR! not ok code 0
how to resolve this issue?
Current npm version - 1.2.24
Current node version - v12.13.0
You are using a very old version of npm.
Use the following command to update npm:
npm install npm#latest