Skip to content

SyntaxError: Cannot use import statement outside a module #36

@enspritz

Description

@enspritz

This error occurs using the example code straight off of the NPM project page with:

  • The supplied RunKit link on the NPM project page, and
  • When trying in a fresh, up-to-date install of gulp.
(node:160771) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
.../gulpfile.js:73
import favicons from 'gulp-favicons';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (node:internal/modules/cjs/loader:1427:18)
    at Module._compile (node:internal/modules/cjs/loader:1449:20)
    at Module._extensions..js (node:internal/modules/cjs/loader:1588:10)
    at Module.load (node:internal/modules/cjs/loader:1282:32)
    at Module._load (node:internal/modules/cjs/loader:1098:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
    at Module.require (node:internal/modules/cjs/loader:1304:12)
    at require (node:internal/modules/helpers:123:16)
    at requireOrImport (.../nodejs/22.5.1/lib/node_modules/gulp/node_modules/gulp-cli/lib/shared/require-or-import.js:20:11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions