Reactjs 获得';找不到模块';nextJS开发构建中出错
我最近创建了一个新的github帐户并克隆了回购协议。它工作得非常好,但在我用新的github帐户克隆了repo之后,每次执行Reactjs 获得';找不到模块';nextJS开发构建中出错,reactjs,redux,next.js,Reactjs,Redux,Next.js,我最近创建了一个新的github帐户并克隆了回购协议。它工作得非常好,但在我用新的github帐户克隆了repo之后,每次执行npm run dev操作时,我都会收到一个错误。该错误似乎与webpack有关,我没有next.config.js。下面是我得到的错误 ready - started server on 0.0.0.0:3000, url: http://localhost:3000 info - Using webpack 5. Reason: no next.config.js
npm run dev
操作时,我都会收到一个错误。该错误似乎与webpack有关,我没有next.config.js。下面是我得到的错误
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Using webpack 5. Reason: no next.config.js https://nextjs.org/docs/messages/webpack5
error - ./src/redux/store.js:1:0
Module not found: Can't resolve './node_modules/redux'
> 1 | import { createStore, applyMiddleware } from './node_modules/redux';
2 | import { persistStore } from 'redux-persist';
3 | import thunk from './node_modules/redux-thunk';
4 |
event - build page: /next/dist/pages/_error
wait - compiling...
error - ./src/redux/store.js:1:0
Module not found: Can't resolve './node_modules/redux'
> 1 | import { createStore, applyMiddleware } from './node_modules/redux';
2 | import { persistStore } from 'redux-persist';
3 | import thunk from './node_modules/redux-thunk';
4 |
Error: Cannot find module 'path/.next/server/pages-manifest.json'
我尝试删除node_模块并重新安装npm。另外,尝试重新安装redux和react redux,但无法解决问题
如果有任何帮助,我将不胜感激
谢谢 请始终按名称导入内容,而不是使用完整的节点路径。这些包可能在您磁盘上的任何位置—节点会找到它们,但您不会总是做出正确的假设 那么,你会使用
import { createStore, applyMiddleware } from 'redux';
import { persistStore } from 'redux-persist';
import thunk from 'redux-thunk';
此外,现在我建议您研究一下官方的Redux工具包,它通常会使您更容易使用Redux,在这种情况下,只需拨打电话就可以为您提供一个完全预配置的存储
import { configureStore } from '@reduxjs/toolkit'
import someReducer from './someSlice'
import otherReducer from './otherSlice'
// thunks are already set up, as well as the devtools
export const store = configureStpre({
reducer: {
some: someReducer,
other: otherReducer
}
})
了解现代redux(包括redux工具包)的最佳方法是遵循请始终按名称导入内容,而不是使用完整的节点路径。这些包可能在您磁盘上的任何位置—节点会找到它们,但您不会总是做出正确的假设 那么,你会使用
import { createStore, applyMiddleware } from 'redux';
import { persistStore } from 'redux-persist';
import thunk from 'redux-thunk';
此外,现在我建议您研究一下官方的Redux工具包,它通常会使您更容易使用Redux,在这种情况下,只需拨打电话就可以为您提供一个完全预配置的存储
import { configureStore } from '@reduxjs/toolkit'
import someReducer from './someSlice'
import otherReducer from './otherSlice'
// thunks are already set up, as well as the devtools
export const store = configureStpre({
reducer: {
some: someReducer,
other: otherReducer
}
})
了解现代redux(包括redux工具包)的最佳方法是遵循它的工作原理!!非常感谢你!!成功了!!非常感谢你!!