np icon indicating copy to clipboard operation
np copied to clipboard

npm version is failing and I have the lastest

Open amejiarosario opened this issue 6 years ago • 19 comments

Description

I'm using npm 6.9.0 and np is still complaining:

image

Steps to reproduce

  1. np

Expected behavior

Go through since my npm is up to date

Environment

np - 5.0.2 Node.js - 10.12.0 npm - 6.9.0 Git - 2.19.1 OS - Mac OS X 10.14.4 (build 18E226)

amejiarosario avatar May 27 '19 13:05 amejiarosario

I am experiencing the same issue using node 10.15.3 and npm 6.9.0. I can make it work by switching to the latest node version (12.3.1), but my whole testing environment expects node 10, so I need to just go --yolo. 😢

malexsan1 avatar May 28 '19 06:05 malexsan1

I couldn't reproduce this locally on my machine (using Node v10.12.0, npm v6.9.0 and np v5.0.2). Can you try running npm i node -e "console.log(require('semver').satisfies('6.9.0', '<6.8.0'))" and comment the output of the command?

itaisteinherz avatar May 28 '19 10:05 itaisteinherz

@itaisteinherz

$ npm i node -e "console.log(require('semver').satisfies('6.9.0', '<6.8.0'))"
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "console.log(require('semver').satisfies('6.9.0', '<6.8.0'))": Tags may not have any characters that encodeURIComponent encodes.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/admejiar/.npm/_logs/2019-05-28T13_54_56_616Z-debug.log

amejiarosario avatar May 28 '19 13:05 amejiarosario

@amejiarosario Sorry, I meant node -e "console.log(require('semver').satisfies('6.9.0', '<6.8.0'))". For some reason the npm i was added.

itaisteinherz avatar May 28 '19 20:05 itaisteinherz

@itaisteinherz

$ node -e "console.log(require('semver').satisfies('6.9.0', '<6.8.0'))"
false

$ npm -v
6.9.0

amejiarosario avatar May 29 '19 13:05 amejiarosario

@amejiarosario I have no idea why you're experiencing this issue 😕 If you could try to debug this yourself and let us know what you come up with that would be awesome, but otherwise I don't think I can do anything to help with this other than change the minimum required version of Node.js to be v12.

itaisteinherz avatar May 29 '19 14:05 itaisteinherz

Possibly silly question, but: How did you install node? How did you install/upgrade npm on that node?

(Used to have similar problems with version checks with older versions of nvm-windows in the past - maybe you two share something like that)

janpio avatar May 29 '19 17:05 janpio

I installed Node using asdf nodejs and updated npm using npm i -g npm

amejiarosario avatar May 29 '19 17:05 amejiarosario

If I were you and wanted to debug this, I would find my local installation of np and add a few console.log to line 88 in https://github.com/sindresorhus/np/blob/71880f97c5527737dbff5c3f9c0b01ac9cade8cb/source/npm/util.js#L86-L92

console.log('npmVersion', npmVersion)
console.log('version(npmVersion)', version(npmVersion)) 

might tell you something.

janpio avatar May 29 '19 18:05 janpio

I tried but console.log were not printed on the stdout. Not sure if they are being redirected. I just commented out line 90 and everything worked :) But, it's annoying, every time I update this package I'd have to comment out the throw error.

amejiarosario avatar May 29 '19 18:05 amejiarosario

Oh right, that list runner thing probably. Then I would add it to the error that is thrown ;)

janpio avatar May 29 '19 18:05 janpio

console.log('npmVersion', npmVersion)
console.log('version(npmVersion)', version(npmVersion)) 

Also:

console.log('version satisfies, version(npmVersion).satisfies('<6.8.0'));

itaisteinherz avatar May 29 '19 18:05 itaisteinherz

My project uses auditjs, which has npm ^5.6.0 as a dependency. await execa.stdout('whereis', ['npm']); shows that it is using "/node_modules/.bin/npm" instead of globally installed npm, which for me is 6.9.0. Is there a way to force np to use the global one? Actually, as np is installed as global anyways, it should imo never try to use local binaries but use global npm.

Seems to be related to this issue: https://github.com/sindresorhus/execa/issues/153#issuecomment-472404357

saulimus avatar Jun 05 '19 07:06 saulimus

@saulimus See #410.

itaisteinherz avatar Jun 05 '19 10:06 itaisteinherz

Having this same issue with Node 12.4.0 (installed via HomeBrew), NPM 6.9.0 (installed via npm i -g npm), and np 5.0.3 (installed via npm i -g np); node -e "console.log(require('semver').satisfies('6.9.0', '<6.8.0'))" just prints false; and I don't believe I have any "local" npm binaries installed: has anyone actually figured out a real solution for this yet?

Anadian avatar Jun 18 '19 05:06 Anadian

@amejiarosario @saulimus @Anadian Can you check out #410 and see if it fixed the issue for you?

itaisteinherz avatar Jun 24 '19 20:06 itaisteinherz

just to give a feedback, I'm using np v5.0.3, following the thread in #410, but I'm still experiencing the problem as the others :(

matjack1 avatar Jul 03 '19 10:07 matjack1

I've managed to solve the issue by reinstalling node (with asdf) and then running the local version of np (yarn run np).

If you do that you have also to run yarn login as only npm login won't be enough.

matjack1 avatar Aug 23 '19 10:08 matjack1

Just to leave another data point and a few bread crumbs. In my case I'm running Linux so YMMV.

I have package npm installed which installs to /usr/bin/npm and is version 3.5.2 or something similarly old. I do have npm installed "globally (via npm i -g npm)" to /usr/local/bin/npm - it's the one that is run by my shell and it's version 6.11.3.

I did a little debugging and found that the exports.version = () => execa.stdout('npm', ['--version']); was picking the npm version from /usr/bin/npm rather than /usr/local/bin/npm.

I'm not sure why there's a difference in $PATH between my shell and the execa, but uninstalling the ubuntu npm package was a simple enough work around.

phBalance avatar Sep 07 '19 17:09 phBalance

No report since 2019, closing

fregante avatar Feb 03 '23 10:02 fregante