NG6-starter: SyntaxError: Unexpected token import - on gulp component

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)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 23 (1 by maintainers)

Most upvoted comments

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.

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

@bastianwegge heh, I’m just going to apologies and walk away 😃

I have the same issue with gulp version 3.9.1. Same error with version 3.9.0. Error: (function (exports, require, module, __filename, __dirname) { ��v ^ SyntaxError: Invalid or unexpected token at createScript (vm.js:53:10) at Object.runInThisContext (vm.js:95:10) at Module._compile (module.js:543:28) at Object.Module._extensions…js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Liftoff.handleArguments (C:\Roaming\npm\node_modules\gulp\bin\gulp.js:116:3)

Details: gulp -v [20:41:44] CLI version 3.9.0 [20:41:44] Local version 3.9.0

OS: windows 10

Just an fyi, still getting this: `[10:09:13] Requiring external module babel-register /Users/guynesher/Work/job-interviews/forecast-xxx-interview/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 (/Users/guynesher/Work/job-interviews/forecast-xxx-interview/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)`

uninstalling / reinstalling gulp does not help (did for both local and global copies). It’s worth noting I did not clone the repo but copy / pasted it into an existing repo

Hi, thanks for the answers. I cloned again the whole git and the command worked just fine, could have been a library problem but now it’s solved 😃

for historical reasons I must sayI’m using Debian on a google cloud VM

@globl, is problem solved? Closing it for now, feel free to start new discussion.