jjk
jjk

Reputation: 595

js-beautify cannot find module node:url

I'm somehow unable to get js-beautify running.
The installation itself already returns warnings (no errors though).

Install

npm install -g js-beautify
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=16 || 14 >=14.18' },
npm WARN EBADENGINE   current: { node: 'v14.17.5', npm: '8.3.0' }
npm WARN EBADENGINE }

added 53 packages, and audited 54 packages in 2s

Run

js-beautify
internal/modules/cjs/loader.js:892
  throw err;
  ^

Error: Cannot find module 'node:url'
Require stack:
- /home/foo/.nvm/versions/node/v14.17.5/lib/node_modules/js-beautify/node_modules/glob/dist/commonjs/glob.js
- /home/foo/.nvm/versions/node/v14.17.5/lib/node_modules/js-beautify/node_modules/glob/dist/commonjs/index.js
- /home/foo/.nvm/versions/node/v14.17.5/lib/node_modules/js-beautify/js/lib/cli.js
- /home/foo/.nvm/versions/node/v14.17.5/lib/node_modules/js-beautify/js/bin/js-beautify.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/home/foo/.nvm/versions/node/v14.17.5/lib/node_modules/js-beautify/node_modules/glob/dist/commonjs/glob.js:5:20)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/foo/.nvm/versions/node/v14.17.5/lib/node_modules/js-beautify/node_modules/glob/dist/commonjs/glob.js',
    '/home/foo/.nvm/versions/node/v14.17.5/lib/node_modules/js-beautify/node_modules/glob/dist/commonjs/index.js',
    '/home/foo/.nvm/versions/node/v14.17.5/lib/node_modules/js-beautify/js/lib/cli.js',
    '/home/foo/.nvm/versions/node/v14.17.5/lib/node_modules/js-beautify/js/bin/js-beautify.js'
  ]
}

Linux

Upvotes: 0

Views: 21

Answers (1)

James Lee
James Lee

Reputation: 1

I have encountered the same issue while installing js-beautify and resolved the issue using the following steps:

  1. Check the js-beautify folder at ./node_modules/.bin/js-beautify
  2. If it exists, remove it and install it again: [sudo] npm install js-beautify -g

Upvotes: 0

Related Questions