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 adding nonexistent import because of a pinia state property named "note"

See original GitHub issue

Environment


  • Operating System: Windows_NT
  • Node Version: v16.14.0
  • Nuxt Version: 3.0.0-27456065.f38cace
  • Package Manager: yarn@1.22.17
  • Builder: vite
  • User Config: dev, env, server, build, css, buildModules, ignore, publicRuntimeConfig, vite
  • Runtime Modules: -
  • Build Modules: @pinia/nuxt@0.1.8, @vueuse/nuxt@8.0.1, ./modules/fonts/index.ts

Reproduction

Repo for reproduction: https://github.com/Bodokh/ReproduceNuxtError

1 .Start server with “nuxi dev” 2. Error in console: Uncaught SyntaxError: The requested module ‘/_nuxt/node_modules/@vueuse/core/index.mjs?v=0335339f’ does not provide an export named ‘note’

Describe the bug

pinia store file: applications.ts `import { defineStore } from “pinia”;

export type ApplicationState = { applications: any; currentCandidate: any; note: any; }

export const useApplicationsStore = defineStore({ id: “applications”, state: () => ({ applications: null, currentCandidate: null, note: null } as ApplicationState), actions: { async fetchApplications() { try { const { $axios } = useNuxtApp();

    const { data } = await $axios.get('/applications');
    this.$patch({
      applications: data
    });

  } catch (err) {
    console.log(err)
  }
},
async fetchCandidate(id) {
  try {
    const { $axios } = useNuxtApp();
    const { data } = await $axios.get(`/applications/${id}`);

    this.$patch({
      note: data.note,
      currentCandidate: data
    });
  } catch (err) {
    console.log(err)
  }
},
async updateNote(note: any) {
  const id = this.currentCandidate.id
  const { $axios } = useNuxtApp();
  try {
    const result = await $axios.post(`/applications/${id}/update-note`, { note: note });

    this.$patch({
      note: note
    })

    return result.status == 200
  } catch (err) {
    console.log(err)

    return false
  }
}

}, getters: { getApplications: state => state.applications } }) `

in the browser this is how the file looks: import { note } from '/_nuxt/node_modules/@vueuse/core/index.mjs?v=0335339f'; // this is the issue import { useNuxtApp } from '/_nuxt/node_modules/nuxt3/dist/app/index.mjs';import { defineStore } from "/_nuxt/node_modules/.vite/pinia_dist_pinia_mjs.js?v=0335339f"; export const useApplicationsStore = defineStore({ id: "applications", state: () => ({ applications: null, .......

When I replaced “note” with “notes” in the file this stopped happening…

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
antfucommented, Mar 19, 2022
0reactions
danielroecommented, Mar 17, 2022

I would check whether you are overriding the process.env.NODE_ENV variable anywhere. Perhaps in a .env file? (You shouldn’t, nor should you specifically set dev in your config.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Usage in Vue2 with TypeScript #1204 - vuejs/pinia - GitHub
I'm working on migrating our (pretty big) Nuxt/TS/Vuex application to a ... import { defineStore } from 'pinia'; export const useCounterStore = defineStore( ......
Read more >
typescript - Vue js 3 - Property 'projects' does not exist on type ...
I have added import { ComponentCustomProperties } from "vue"; import { Store } from "vuex"; declare module "@vue/runtime-core" { interface ...
Read more >
State | Pinia
In Pinia the state is defined as a function that returns the initial state. This allows Pinia to work in both Server and...
Read more >
Setup Pinia in Nuxt 3 - DEV Community ‍ ‍
To setup Pinia store add the Nuxt build module configuration, in nuxt-config ... getUser: (state)=> { state.name } } }) if (import.meta.hot) ...
Read more >
Complex Vue 3 state management made easy with Pinia
Here, we import and extract all necessary data from post store. We can't use destructuring for state properties and getters because they will ......
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