Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

449
Views
SyntaxError: Unexpected token import - import * as gulp from 'gulp'

If you run gulp, you will get the following error message.

Is module required for gulpfile not installed? ..

$ gulp
[22:17:15] Failed to load external module ts-node/register
[22:17:15] Failed to load external module typescript-node/register
[22:17:15] Failed to load external module typescript-register
[22:17:15] Failed to load external module typescript-require
C:\project\interview\gulpfile.ts:1
(function (exports, require, module, __filename, __dirname) { import * as gulp f                                 rom 'gulp';
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Liftoff.handleArguments (C:\Users\admin\AppData\Roaming\npm\node_modules\gu                                 lp\bin\gulp.js:116:3)
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

There are 3 things you need to do to make gulp work with ES6 imports:

  1. Rename gulpfile.js to gulpfile.babel.js

  2. Run this command:

npm i @babel/preset-env @babel/register -D
  1. Add a .babelrc file to the root folder of your project with the following code in it:
{
  "presets": [
    "@babel/preset-env"
  ]
}

You should now be able to use ES6 imports in your Gulp files.

Note: if you want to use TypeScript in your Gulp files instead, you should follow the steps outlined here:

https://stackoverflow.com/a/49849088/1611058

over 4 years ago · Santiago Trujillo Report

0

1) Create a ".babelrc" file in your Projekt folder (where also all your other config files are)

  • Code (.babelrc)

    { "presets": ["es2015"] }

2) Setup/Install the Babel in your NPM (see https://babeljs.io/setup). E. g. with Node:

npm install babel-preset-env --save-dev

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!