EN
Node.js - Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\path1' imported from C:\path2
1
answers
3
points
Can you help me with the following error?
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\path\to\file1.js' imported from C:\path\to\file2.js
I'm using ES Modules in my Node.js project (I've added "type": "module"
to package.json
file).
1 answer
3
points
You probably didn't specify the file extension. When you are using ES Modules import/export in pure JS in Node.js, you need to remember that when you are importing modules.
Practical example
Instead of:
import { myVariable } from './myModule';
use:
import { myVariable } from './myModule.js';
See also
0 comments
Add comment