kingkongdevs / posthtml-picture-srcset

MIT License
1 stars 0 forks source link

Error when importing the plugin #1

Open Ulyanov-programmer opened 1 year ago

Ulyanov-programmer commented 1 year ago

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 think you just forgot to add a "type": "module", to your package.json. There was a time when I also made such a mistake.

kingkongdevs commented 1 year ago

Hey we just updated this, there was a single import inside that we've changed to require the function instead. Try the new version on NPM.

Ulyanov-programmer commented 1 year ago

Great! But alas, that's not all. I updated the module and got the following error:

Error: Cannot find module 'globby'
Require stack:
- G:\gulp_multitool\node_modules\posthtml-picture-srcset\lib\inc\rollup-images.js
- G:\gulp_multitool\node_modules\posthtml-picture-srcset\lib\pictureSrcset.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    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\lib\inc\rollup-images.js:9:14)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    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) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'G:\\gulp_multitool\\node_modules\\posthtml-picture-srcset\\lib\\inc\\rollup-images.js',
    'G:\\gulp_multitool\\node_modules\\posthtml-picture-srcset\\lib\\pictureSrcset.js'
  ]
}

I tried reinstalling node_modules, it didn't help.

I have not encountered this :(