I have a file, test.js
with these lines of code inside:
import {blabla} from "./bla";
async function dataGenerator() {
..........
}
(async() => {
console.log('1')
await dataGenerator()
console.log('2')
})()
Note: Ignore the import structure. It is just fictive for the question. In my file the imports are auto.
When I'm trying to run from terminal with node test.js
it returns error:
Cannot find module 'D:\bla' imported from D:\test.js
I have added into package.json
the line: "type": "module"
. Without this it returns:
Cannot use import statement outside a module
I'm using node v14
. How can I run the test.js
without adding to all the imports ".js"
. There are functions in functions in functions and is complicated to add .js
extension. Is there any npm to run it?