Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Plugin not working with Nuxt 2 #23

Closed
Jamiewarb opened this issue Dec 22, 2021 · 2 comments
Closed

Plugin not working with Nuxt 2 #23

Jamiewarb opened this issue Dec 22, 2021 · 2 comments

Comments

@Jamiewarb
Copy link

Jamiewarb commented Dec 22, 2021

Hey there,

I followed the integration instructions in the documentation and am receiving an error.

I've created a reproduction here: https://github.com/hex-digital/nuxt-2/tree/pinia-persist and a PR to see it more easily here (hex-digital/nuxt-2#1)

It's set up by:

  • Install Nuxt via yarn create nuxt-app fresh-nuxt
  • Add deps via yarn add -D pinia @pinia/nuxt @nuxtjs/composition-api pinia-plugin-persist
  • Add entries to buildModules as per this plugins docs
buildModules: [
  '@nuxtjs/composition-api/module',
  '@pinia/nuxt',
  'pinia-plugin-persist/nuxt',
];

Steps to reproduce

  • Run yarn dev
  • Observe error in terminal:
❯ yarn dev
yarn run v1.22.17
$ nuxt

 FATAL  Package subpath './nuxt' is not defined by "exports" in /Users/jamie/Sites/bignight/fresh-nuxt/node_modules/pinia-plugin-persist/package.json

  at new NodeError (node:internal/errors:371:5)
  at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
  at packageExportsResolve (node:internal/modules/esm/resolve:692:3)
  at resolveExports (node:internal/modules/cjs/loader:482:36)
  at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
  at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
  at Function.resolve (node:internal/modules/cjs/helpers:108:19)
  at p (node_modules/jiti/dist/jiti.js:1:52925)
  at Resolver.g [as _require] (node_modules/jiti/dist/jiti.js:1:54200)
  at Resolver.requireModule (node_modules/@nuxt/core/dist/core.js:381:29)


   ╭────────────────────────────────────────────────────────────────────────────────────────────────────╮
   │                                                                                                    │
  1 export default {
   │   ✖ Nuxt Fatal Error                                                                               │
   │                                                                                                    │
   │   Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './nuxt' is not defined by "exports" in   │
   │   /Users/jamie/Sites/bignight/fresh-nuxt/node_modules/pinia-plugin-persist/package.json            │
   │                                                                                                    │
   ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

image

Other Notes

Note that for Nuxt, the Pinia docs say to add @pinia/nuxt to buildModules, but this plugins docs say to add pinia/nuxt. Adding pinia/nuxt as you suggest gives a similar error relating to pinia.

@Jamiewarb Jamiewarb changed the title Plugin not working with Nuxt 2 Plugin not working with Pinia v2 and Nuxt 2 Dec 22, 2021
@Jamiewarb Jamiewarb changed the title Plugin not working with Pinia v2 and Nuxt 2 Plugin not working with Nuxt 2 Dec 22, 2021
@Jamiewarb
Copy link
Author

Jamiewarb commented Dec 22, 2021

I imagine the docs may just need to change to demonstrate integrating this plugin via a Nuxt Plugin, unless you'd prefer having a nuxt package, similar to how Pinia has one, that can be added as a buildModule?

What do you think?

@Seb-L
Copy link
Owner

Seb-L commented Mar 10, 2022

I'm gonna work on nuxt2 and 3 plugins soon, I just updated the documentation on how to use it with nuxt 2 by creating a nuxt plugin: https://seb-l.github.io/pinia-plugin-persist/

@Seb-L Seb-L closed this as completed Mar 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants