Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

448
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda