Answer the question
In order to leave comments, you need to log in
SyntaxError: Cannot use import statement outside a module?
NodeJs version 12.
Swears on any import. require works fine, but it became interesting why the import does not work and what is this strange error (I did not find an answer in Google).
You can't use imports outside of a module, but how can you define that module? import express from 'express'
Answer the question
In order to leave comments, you need to log in
Decided using this
let app = 123;
module.exports = { app }
const { app } = require('./app')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question