question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Unexpected token import - on gulp component

See original GitHub issue

Hello,

I’m trying to scaffold a component with a fresh clone, the command is gulp component --name storage

the error is

[16:18:38] Requiring external module babel-register /var/www/other/boil/gulpfile.babel.js:3 import gulp from ‘gulp’; ^^^^^^

SyntaxError: Unexpected token import at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:387:25) at loader (/var/www/other/boil/node_modules/babel-register/lib/node.js:158:5) at Object.require.extensions.(anonymous function) as .js at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Module.require (module.js:367:17) at require (internal/module.js:16:19) at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3) at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:193:16)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:23 (1 by maintainers)

github_iconTop GitHub Comments

38reactions
mpavelcommented, Apr 14, 2017

Go to babel website, Installation section, and select “Gulp” - http://babeljs.io/docs/setup/#installation

Take a look at step 4 - you will need to create a .babelrc configuration file and use a babel-preset. This resolved the issue for me.

4reactions
frkgrallcommented, Jul 31, 2017

For me, I just forgot to cp the .babelrc file, with it it’s okay 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token import - import * as gulp from ...
It looks as though you are using a gulpfile.ts dynamically compiled by ts-node. That's fine but you need to target NodeJS's module system,...
Read more >
Unexpected token import with gulp - Eric L. Anderson
I have started to play with the release version of Aurelia. My current goal is to see what it takes to get going...
Read more >
import path from "node:path" - unexpected identifier - You.com
appSrc isn't something defined on the node path module. Try using path.resolve(__dirname, 'src') - the example in their docs is creating/importing a paths...
Read more >
Gulp + browserify + babelify: "Unexpected token" for JSX code ...
Coding example for the question Gulp + browserify + babelify: "Unexpected ... + browserify-rails + react, Uncaught SyntaxError: Unexpected token import ...
Read more >
SyntaxError: Unexpected token 'export' in JavaScript [Fixed]
To solve the "Uncaught SyntaxError Unexpected token 'export'" error, set the type property to module in your package.json file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found