HOW TO FIX SyntaxError: Cannot use import statement outside a module

Опубликовано: 09 Август 2022
на канале: ToastyBits
39k
204

Are you using imports in a node.js application and running into the SyntaxError: Cannot use import statement outside a module error?

Here are 3 ways to fix this error.

If you're developing a JavaScript application, then add "type": "module" into your package.json file.
If you're developing a TypeScript application, then make sure "module" is set to "commonjs" in your tsconfig.json file.
If you're importing a script in a HTML file, then add type="module" into the script tag.


Смотрите видео HOW TO FIX SyntaxError: Cannot use import statement outside a module онлайн без регистрации, длительностью 01 минут 21 секунд в хорошем hd качестве. Это видео добавил пользователь ToastyBits 09 Август 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 39 тысяч раз и оно понравилось 204 людям.