Skip to content
Advertisement

Node –experimental-modules – Error: Cannot find module

I am getting an error when trying to import a local file, though no problem when using npm packages.

server.js

JavaScript

api.js

JavaScript

Starting app

JavaScript

Error

JavaScript

Advertisement

Answer

I’m answering my own question if anybody else has this problem.

It turns out in experimental mode you need to define the full path with extension. So I am trying to import index.js thinking it will know.

To fix it:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement