Open
Description
This Stack Overflow post explains how to use TypeScript on the primary gulp file.
Those steps work successfully for the main gulpfile.ts and outputs this line to the console when you run gulp
Requiring external module ts-node/register
What were you expecting to happen?
After running the following command:
gulp --gulpfile customGulpFile.ts
I expect it to run Requiring external module ts-node/register
like it does when compiling the main gulp file.
What actually happened?
I run this command:
gulp --gulpfile customGulpFile.ts
And I get the following error:
import * as gulp from 'gulp'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1054:16)
at Module._compile (internal/modules/cjs/loader.js:1102:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at requireOrImport (xxxxxx\node_modules\gulp\node_modules\gulp-cli\lib\shared\require-or-import.js:19:11)
at execute (xxxxxx\node_modules\gulp\node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:37:3)
at Liftoff.handleArguments (xxxxxx\node_modules\gulp\node_modules\gulp-cli\index.js:211:24)
Please give us a sample of your gulpfile
The "converting-gulp-files-to-typescript" branch of my gulp-auto-imports repository demonstrates the bug.
Do the following steps to reproduce:
- Checkout/Fork the repo
- Run
npm install
- Run
npm run generate
(uses the non-primary gulp files)
A working version that is not using TypeScript can be found on the "feature/TypeScript-preset" branch.
Terminal output / screenshots
Please provide the following information:
- OS & version [e.g. MacOS Catalina 10.15.4]: Windows 10 Home v1909
- node version (run
node -v
): v12.18.2 - npm version (run
npm -v
): v6.14.5 - gulp version (run
gulp -v
): CLI v2.3.0; Local v4.0.2