Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

“SyntaxError: Cannot use import statement outside a module”: occurs on Ubuntu, but not on Windows

Writer Mia Lopez

I work with this assembly:

It works for me on Windows. But on Ubuntu, right after the run command (gulp, or npm run dev, or yarn run dev) does not start and gives the following error:

paranoic:~/PhpstormProjects/20_18$ gulp
[14:27:25] Requiring external module @babel/register
/home/paranoic/PhpstormProjects/project10/gulpfile.babel.js:3
import gulp from "gulp";
^^^^^^
SyntaxError: Cannot use import statement outside a module

Everywhere they write that these are troubles with babel. But why are they on one OS and not the other?

I have already taken the following measures, but they did not work:

  • Just in case, I checked some other assembly is running on Ubuntu. There is an assembly without imports - it starts

  • I changed the version of node to the one that supports modules and added an entry "type": "module" to the package

What should I do to make the build work on Ubuntu?

6 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy