question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nuxt configuration is not working for Nuxt2.x (Cannot find module '#app')

See original GitHub issue

Says in documentation that plugin works in Nuxt 2, but example in documentation is not working.

`TS2307: Cannot find module ‘#app’ or its corresponding type declarations. 1 | import { createNuxtPersistedState } from ‘pinia-plugin-persistedstate’

2 | import { defineNuxtPlugin, useCookie } from ‘#app’ | ^^^^^^ 3 | 4 | export default defineNuxtPlugin(nuxtApp => { 5 | nuxtApp.$pinia.use(createNuxtPersistedState(useCookie))`

Removing this line and trying to do correct import statements, will lead to errors for useCookie(not found)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
larenelgcommented, Jun 20, 2022

I’m not sure about Cookies, but I hope this helps for Nuxt 2:

plugins/persistedStatePlugin.js

import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

const persistedStatePlugin = ({ $pinia }) => {
  $pinia.use(piniaPluginPersistedstate)
}

export default persistedStatePlugin

nuxt.config.js

  plugins: [
    '~/plugins/persistedStatePlugin.js'
  ],
0reactions
prazdevscommented, Jun 27, 2022

name your file plugins/persistedStatePlugin.client.js to make it clientside only, that way it won’t try to access to localStorage while server side rendering

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot start nuxt: Cannot find module 'nuxt' #3060 - GitHub
Nuxt CLI v3.0.0-27398533.8edd481 > Local: http://localhost:3000/ ERROR Cannot start nuxt: Cannot find module 'nuxt' Require stack: - /nuxt3-app/index.js.
Read more >
Configuration - Nuxt
Nuxt lets you define the CSS files/modules/libraries you want to set globally (included in every page). In case you want to use sass...
Read more >
Nuxt configuration file
Nuxt configuration file. By default, Nuxt is configured to cover most use cases. This default configuration can be overwritten with the nuxt.config.js file....
Read more >
Installation - Nuxt
Here, you will find information on setting up and running a Nuxt project in 4 steps. ... To get started quickly, you can...
Read more >
Installation | Nuxt Image
Using image module in your Nuxt project is only one command away. ... Add the module to buildModules in your nuxt.config : nuxt.config.js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found