Skip to content

Error when importing the plugin #1

Description

@Ulyanov-programmer

An error occurred while trying to import and use your module:

import { generateAll } from './inc/rollup-images.js'
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:74:18)
    at wrapSafe (node:internal/modules/cjs/loader:1141:20)
    at Module._compile (node:internal/modules/cjs/loader:1182:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (G:\gulp_multitool\node_modules\posthtml-picture-srcset\index.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
  • I imported your module using import pictureSrcset from 'posthtml-picture-srcset'
  • I'm using your module in Gulp
.pipe(posthtml([
      easyBem(),
      pictureSrcset({
        imageOptions: {
          quality: 100,
          inputFormat: ['jpg', 'jpeg', 'png'],
          outputFormat: ['webp', 'avif'],
        }
      })
    ], {}))
  • In my package.json is a string "type": "module",

I think you just forgot to add a "type": "module", to your package.json. There was a time when I also made such a mistake.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions