markdownlint-cli icon indicating copy to clipboard operation
markdownlint-cli copied to clipboard

Error: Cannot find module 'node:path'

Open HatemMn opened this issue 1 year ago • 3 comments

I am working on an Ubuntu

I also have node js installed with the latest version

When I try to run the pre commit hook of markdownlint-cli, I get the following error :

[INFO] Installing environment for https://github.com/igorshubovych/markdownlint-cli.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/myname/.cache/pre-commit/repo2p9gi6xg/node_env-system/bin/node', '/usr/local/bin/npm', 'install', '--include=dev', '--include=prod', '--ignore-prepublish', '--no-progress', '--no-save')
return code: 1
stdout: (none)
stderr:
    internal/modules/cjs/loader.js:818
      throw err;
      ^
    
    Error: Cannot find module 'node:path'
    Require stack:
    - /usr/local/lib/node_modules/npm/lib/cli.js
    - /usr/local/lib/node_modules/npm/bin/npm-cli.js
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
        at Function.Module._load (internal/modules/cjs/loader.js:667:27)
        at Module.require (internal/modules/cjs/loader.js:887:19)
        at require (internal/modules/cjs/helpers.js:85:18)
        at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/cli.js:2:18)
        at Module._compile (internal/modules/cjs/loader.js:999:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
        at Module.load (internal/modules/cjs/loader.js:863:32)
        at Function.Module._load (internal/modules/cjs/loader.js:708:14)
        at Module.require (internal/modules/cjs/loader.js:887:19) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [
        '/usr/local/lib/node_modules/npm/lib/cli.js',
        '/usr/local/lib/node_modules/npm/bin/npm-cli.js'
      ]
    }
Check the log at /home/myname/.cache/pre-commit/pre-commit.log

What can the problem be ? I deleted and reinstalled node many times

HatemMn avatar Oct 11 '24 16:10 HatemMn

Minimum supported Node version is 18. It sounds like you are on something much older. I think the default Ubuntu apt repository has not been updated in years.

https://github.com/igorshubovych/markdownlint-cli/blob/aa975a18c9a869648007d33864034dbc7481fe5e/package.json#L10

DavidAnson avatar Oct 11 '24 18:10 DavidAnson

Thanks for your reply @DavidAnson

I checked my node version and it is all right with the requirements

node --version
v22.9.0

Still the exact same bug stated above

HatemMn avatar Oct 14 '24 08:10 HatemMn

Please have a look at the version of Node that's being used by pre-commit - I don't think that tool uses the system version. Issue #157 has more detail on this scenario.

DavidAnson avatar Oct 14 '24 15:10 DavidAnson