K
K
ktotitakoy2022-04-18 20:07:24
JavaScript
ktotitakoy, 2022-04-18 20:07:24

Unexpected template string - What is the error when running Gulp?

On startup it gives the following error:

SyntaxError: Unexpected template string
    at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:115:18)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:289:14)


File nesting:
625d91503e64c942198110.png

package.json:
{
  "name": "gulp-start",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "gulp": "^4.0.2"
  }
}


path.js:
import * as nodePath from `path`
const rootFolder = nodePath.basename(nodePath.resolve())

const buildFolder = `./dist`
const srcFolder = `./src`

export const path = {
   build: {
      files: `${buildFolder}/files/`
   },
   src: {
      files: `${srcFolder}/files/**/*.*`,
   },
   watch: {},
   clean: buildFolder,
   buildFolder: buildFolder,
   srcFolder: srcFolder,
   rootFolder: rootFolder,
   ftp: ``,
}


gulpfile.js:
// Основной модуль
import gulp from "gulp"
// Импорт путей
import { path } from "./gulp/config/path.js"

// Передаем значение в глобальную переменную 
global.app = {
   path: path,
   gulp: gulp,
}


// Импорт задач
import { copy } from "./gulp/tasks/copy.js"


// Выполнение сценария по умолчанию
gulp.task(`default`, copy)


copy.js:
export const copy = () => {
   return app.gulp.src(app.path.src.files)
      .pipe(app.gulp.dest(app.path.build.files))
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2022-04-18
@ralphich

import * as nodePath from "path"
Imports do not support template strings.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question