Skip to content

[BUG] npm install -g npm may break npm installation #555

Closed
@dimaqq

Description

@dimaqq

I got this notification (on git commit, I'm not sure how exactly, maybe pre-commit hook in package.json or some shell integration)

   ╭────────────────────────────────────────────────────────────────╮
   │                                                                │
   │      New patch version of npm available! 6.13.1 → 6.13.2       │
   │   Changelog: https://github.com/npm/cli/releases/tag/v6.13.2   │
   │               Run npm install -g npm to update!                │
   │                                                                │
   ╰────────────────────────────────────────────────────────────────╯

So I tried to upgrade npm globally...

First run:

… ~/someproject> npm install -g npm
npm WARN remove Error: EACCES: permission denied, unlink '/usr/local/lib/node_modules/.npm.MODULES/agentkeepalive/README.md'
npm WARN remove  [Error: EACCES: permission denied, unlink '/usr/local/lib/node_modules/.npm.MODULES/agentkeepalive/README.md'] {
npm WARN remove   stack: "Error: EACCES: permission denied, unlink '/usr/local/lib/node_modules/.npm.MODULES/agentkeepalive/README.md'",
npm WARN remove   errno: -13,
npm WARN remove   code: 'EACCES',
npm WARN remove   syscall: 'unlink',
npm WARN remove   path: '/usr/local/lib/node_modules/.npm.MODULES/agentkeepalive/README.md'
npm WARN remove }
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
+ npm@6.13.2
updated 1 package in 5.564s

Partially failed, partially succeeded.

Let's test it:

… ~/someproject> npm install -g npm
internal/modules/cjs/loader.js:783
    throw err;
    ^

Error: Cannot find module 'semver'
Require stack:
- /usr/local/lib/node_modules/npm/lib/utils/unsupported.js
- /usr/local/lib/node_modules/npm/bin/npm-cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:780:15)
    at Function.Module._load (internal/modules/cjs/loader.js:685:27)
    at Module.require (internal/modules/cjs/loader.js:838:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
    at Module._compile (internal/modules/cjs/loader.js:945:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
    at Module.load (internal/modules/cjs/loader.js:798:32)
    at Function.Module._load (internal/modules/cjs/loader.js:711:12)
    at Module.require (internal/modules/cjs/loader.js:838:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/npm/lib/utils/unsupported.js',
    '/usr/local/lib/node_modules/npm/bin/npm-cli.js'
  ]
}

Uh-oh, it's broken now :(

Surely it's an artefact of my installation being somehow half-assed in the first place, but this is a bummer...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions