Skip to content

Can't run npm on node 18.12.1 on Linux #45329

Closed as not planned
Closed as not planned
@vvvbbbcz

Description

@vvvbbbcz

Version

18.12.1 (the archive downloaded directly from site)

Platform

Linux 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

npm

What steps will reproduce the bug?

Only run npm.

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior?

node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module '../lib/cli.js'
Require stack:
- /home/misaka/Libs/node-v18.12.1-linux-x64/bin/npm
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/misaka/Libs/node-v18.12.1-linux-x64/bin/npm:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/misaka/Libs/node-v18.12.1-linux-x64/bin/npm' ]
}

Node.js v18.12.1

What do you see instead?

node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module '../lib/cli.js'
Require stack:
- /home/misaka/Libs/node-v18.12.1-linux-x64/bin/npm
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/misaka/Libs/node-v18.12.1-linux-x64/bin/npm:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/misaka/Libs/node-v18.12.1-linux-x64/bin/npm' ]
}

Node.js v18.12.1

Additional information

When I edit node-v18.12.1-linux-x64/bin/npm from:

#!/usr/bin/env node
require('../lib/cli.js')(process)

To:

#!/usr/bin/env node
require('../lib/node_modules/npm/lib/cli.js')(process)

The problem will be solved. But I don't how to make contribution, because I can't understand your source code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    npmIssues and PRs related to the npm client dependency or the npm registry.wrong repoIssues that should be opened in another repository.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions