Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

452
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda