Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] After update to npm 7 it seems no global packages are recognized #2002

Closed
charles-dexter-ward opened this issue Oct 21, 2020 · 17 comments
Assignees
Labels
Bug thing that needs fixing platform:windows is Windows-specific Release 7.x work is associated with a specific npm 7 release

Comments

@charles-dexter-ward
Copy link

Upgraded from node 14 to node 15.0.0
Upgraded npm to 7.0.3

Current Behavior:

  1. npm --outdated -g
    only shows a DOWNGRADE from npm 7 to 6
    image

  2. npm list -g --depth= 0
    it does not show the intalled global packages, but only npm
    image

Expected Behavior:

the complete list of installed global packages should be listed.

Steps To Reproduce:

Environment:

  • OS: Windows 10
  • Node: 15.0.0
  • npm: 7.0.3
@charles-dexter-ward charles-dexter-ward added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Oct 21, 2020
@charles-dexter-ward
Copy link
Author

charles-dexter-ward commented Oct 21, 2020

In addition there is also the issue #1962
image

@WraithKenny
Copy link

I had this same problem on my MacOS system, but fixed it with
brew rm node
brew install node
Which doesn't explain why the problem also happens on Windows, but maybe it points to where the problem is.

(It seems on upgrade it loses track of where the global node_modules folder is, but install knows where it is? I dunno.)

Didn't fix the "global requires an add or rm option" tho.

@WraithKenny
Copy link

What's also strange is that npm i npm@^6 -g didn't fix the issue, only an uninstall and reinstall of node

@funfunction
Copy link

funfunction commented Oct 24, 2020

After installing node 15 and npm 7, the npm global modules install into this path...
C:\Program Files\nodejs\node_modules

instead of....
C:\Users\USER\AppData\Roaming\npm\node_modules

Which path should be made the canonical path to use?

@charles-dexter-ward
Copy link
Author

#1962 (comment)

could solve the problem for someone (not for me #1962 (comment))

@jonathanmarvens
Copy link

#1962 (comment)

@funfunction
Copy link

Installing Node 15 fresh (uninstall first) still installs only npm 6 (not npm 7)

Is this the expected behavior or a bug?

node, npm, older version

@charles-dexter-ward
Copy link
Author

@funfunction
Npm 7 is not the latest, I suppose. I think you must explictly require the version 7.

@ljharb
Copy link
Contributor

ljharb commented Nov 5, 2020

@funfunction if you have installed node 15 properly, it will always come with npm 7. If it doesn't, your install method is likely broken.

@nickserv
Copy link

nickserv commented Nov 6, 2020

I think it's more about npm 7's global package linking being broken (since npm itself is an npm package)

@ljharb
Copy link
Contributor

ljharb commented Nov 6, 2020

@nickmccurdy on a fresh install of node, npm isn’t linked, and on any node 15, it’s always npm 7.

@funfunction
Copy link

I fixed it by cd-ing into AppData\Roaming\npm

then running: npm link npm

After 10 years of using node, this is the first time I had to do this.

@charles-dexter-ward
Copy link
Author

Installed npm 7.0.10 (which should fix #1962) :

npm outdated -g
image

npm list -g --depth=0
image

npm link npm
image

`
42 verbose stack Error: ELOOP: too many symbolic links encountered, stat 'C:\Users\XXXXX\node_modules\npm'

42 verbose stack at eloop (C:\Users\XXXXX\node_modules\npm\node_modules@npmcli\arborist\lib\realpath.js:57:17)

42 verbose stack at C:\Users\XXXXX\node_modules\npm\node_modules@npmcli\arborist\lib\realpath.js:82:15

42 verbose stack at async Arborist.[loadActual] (C:\Users\XXXXX\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\load-actual.js:118:13)

`

@darcyclarke darcyclarke added platform:windows is Windows-specific and removed Needs Triage needs review for next steps labels Nov 11, 2020
@charles-dexter-ward
Copy link
Author

I had to reinstall all global packages. Now they are listed by npm and executable.
Before reinstalling them, there were no binaries in the node_modules folder even if the packages were previously installed.

@darcyclarke darcyclarke added this to the OSS - Sprint 20 milestone Nov 16, 2020
@darcyclarke darcyclarke assigned nlf and isaacs and unassigned nlf Nov 16, 2020
isaacs added a commit that referenced this issue Nov 17, 2020
When a file named 'npmrc' is in the root of the npm module that is
currently running, it adds config values that override the defaults (but
not the global or user configs).

This is a way for a system package installer to tell the npm that it
installs to put its globals somewhere other than the default.  In order
to keep these configs around when users self-update npm with `npm i -g
npm`, these config values must be "sticky", and ride along into the
newly globally installed npm.

This commit restores this behavior, fixing self-updating npm for Windows
users, and any other systems that may make use of this functionality.

Fixes: #2002
@WraithKenny
Copy link

WraithKenny commented Nov 19, 2020

So I had
which npm > /usr/local/bin/npm,
npm -v > 7.0.10
npm -g ls --depth=0 shows usr/local/lib
and npm config list showed

; "builtin" config from /usr/local/lib/node_modules/npm/npmrc

prefix = "/usr/local" 

; "cli" config from command line options

omit = [] 
user-agent = "npm/7.0.10 node/v15.2.1 darwin x64" 

; node bin location = /usr/local/Cellar/node/15.2.1/bin/node
[...]

Then I run npm install -g npm@7.0.12
Now...
which npm > /usr/local/bin/npm,
npm -v > 7.0.12
npm -g ls --depth=0 shows /usr/local/Cellar/node/15.2.1/lib
and npm config list shows

; "cli" config from command line options
[...]

...which fails to load the previous (default) prefix. (npm config list -l will show prefix = "/usr/local/Cellar/node/15.2.1")

This still seems like it's off. I've fixed mine by adding a .npmrc (by running npm config set prefix /usr/local) but if a user upgrades without that file, things are weird.

@playpiano
Copy link

even last version 7.3.0 not listing globally installed packages: is it a new Arborist tree list bug?

@charles-dexter-ward
Copy link
Author

Yes. I had installed 7.2.0 and it has screwed up the packages again. :(
What the hell!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing platform:windows is Windows-specific Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants