soc221b/pinia-plugin-persistedstate-2

ES module conflict with node_modules/pinia-plugin-persistedstate-2/dist/index.es.prod.js

speedyvic opened this issue · 1 comments

Error
Using persistedstate-2 with Nuxt 3 (Vite), got the following error

(node:3690) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. .../node_modules/pinia-plugin-persistedstate-2/dist/index.es.prod.js:1

Environment

  • Node v16.11.1 and v17.2.0
  • Nuxt CLI v3.0.0-27338323.1e98259
  • pinia-plugin-persistedstate-2 0.2.7 but also found on 0.2.6
  • pinia 2.0.9

To Reproduce
Use the Nuxt3 demo from your project

Temp Fix

  1. Changed extension of file pinia-plugin-persistedstate-2/dist/index.es.prod.js to pinia-plugin-persistedstate-2/dist/index.es.prod.mjs
  2. Changed package.json from your project
    "module": "dist/index.es.prod.mjs",

Setting "type": "module" does not work

After that, Nitro will correctly run the plugin and it works correctly. BTW, thanks a lot for your hard work. I though in opening this because this is going to bite us later when Nuxt 3 is released. I'm supposing that this is happening by using Vite only, but have not tested.

@speedyvic
This bug is fixed and released in 0.2.8.

Thanks you for your feedback 😄 .