user9542625
user9542625

Reputation:

Trying to access node REPL produces Error: Cannot find module 'esm'

I'm using Kubuntu 20.04.1 and I just installed the current version of node trough nvm (14.8.0), now when trying to access the node REPL by just typing node, I got this error message:

$ node
internal/modules/cjs/loader.js:1083
  throw err;
  ^

Error: Cannot find module 'esm'
Require stack:
- internal/preload
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
    at Function.Module._load (internal/modules/cjs/loader.js:923:27)
    at Module.require (internal/modules/cjs/loader.js:1140:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1397:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:446:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:74:3)
    at internal/main/repl.js:19:1 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'internal/preload' ]
} 

Any advice about what's going on and how to fix it is welcome

Upvotes: 3

Views: 2000

Answers (1)

user9542625
user9542625

Reputation:

I'm answering my own question in the event someone else faces the same problem: To access the node REPL just install the esm package globally:

npm install -g esm

Or if just require the packae for a project, whitin yout project folder:

npm i esm

For more informatión check this link.

Upvotes: 2

Related Questions