programing

모듈을 찾을 수 없음: 오류:'/myapp/src/store'에서 'vuex'를 확인할 수 없습니다.

prostudy 2022. 7. 29. 22:20
반응형

모듈을 찾을 수 없음: 오류:'/myapp/src/store'에서 'vuex'를 확인할 수 없습니다.

Vue/Vuex가 있다.
Vue.js 앱에서 로그인 기능을 만들려고 하는데 프로젝트에 Vuex를 설치했는데 다음과 같은 오류가 나타납니다.

./src/store/index.js
Module not found: Error: Can't resolve 'vuex' in '/myapp/src/store'
// package.json

"dependencies": {
  "axios": "^0.19.2",
  "core-js": "^2.6.5",
  "vue": "^2.6.10",
  "vue-router": "^3.4.2",
  "vuex": "^3.5.1"
},
// src/store/index.js

import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    userId: "",
    userToken: ""
  },
  mutations: {
    updateUser(state, user) {
      state.userId = user.userId;
      state.userToken = user.userToken;
    }
  },
  actions: {
    auth(context, user) {
      context.commit('updateUser', user);
    }
  },
  modules: {},
})

export default store

이 문제를 해결할 방법이 있나요?

1월 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일 1일@next를 참조해 주세요.

예를 들어 다음과 같습니다.

npm install --save vuex@next

이게 도움이 됐으면 좋겠다.

npm i 되지 않았을 것이다

한번 .import Vuex from 'Vuex'Import " " " " " " 。

저도 이 오류에 직면해 있었습니다.이런 것들이 제게는 효과가 있었습니다.

  1. 에디터를 재기동합니다.(내 경우 웹스톰) 새로 추가된 파일/폴더(노드 모듈)가 인식되지 않을 수 있습니다.
  2. ★★node_modules ★★★★★★★★★★★★★★★★★」yarn.lock을 사용하다
  3. "vuex"에서 Vuex를 Import하거나 "Vuex"에서 Vuex를 Import합니다.

언급URL : https://stackoverflow.com/questions/63335821/module-not-found-error-cant-resolve-vuex-in-myapp-src-store

반응형