我正在尝试构建一个包含react redux的vite应用程序,它给了我这个错误:
$ pnpm build
> temp-vite@1.0.0 build
> tsc && vite build
vite v4.3.9 building for production...
✓ 639 modules transformed.
✓ built in 1.67s
"createContext" is not exported by "../../node_modules/.pnpm/react@18.2.0/node_modules/react/index.js", imported by "../../node_modules/.pnpm/react-redux@8.0.5_@types+react-dom@18.0.11_@types+react@18.0.37_react-dom@18.2.0_react@18.2.0_redux@4.2.1/node_modules/react-redux/es/components/Context.js".
file: .pnpm/react-redux@8.0.5_@types+react-dom@18.0.11_@types+react@18.0.37_react-dom@18.2.0_react@18.2.0_redux@4.2.1/node_modules/react-redux/es/components/Context.js:1:9
1: import { createContext } from 'react';
^
2: export const ReactReduxContext = /*#__PURE__*/createContext(null);
error during build:
RollupError: "createContext" is not exported by "../../node_modules/.pnpm/react@18.2.0/node_modules/react/index.js", imported by "../../node_modules/.pnpm/react-redux@8.0.5_@types+react-dom@18.0.11_@types+react@18.0.37_react-dom@18.2.0_react@18.2.0_redux@4.2.1/node_modules/react-redux/es/components/Context.js".
ELIFECYCLE Command failed with exit code 1.
有办法解决吗
1条答案
按热度按时间wz8daaqr1#
这对我很有效-在rollupOptions/external React context missing in Vite monorepo中添加问题库,你也可以尝试这个-添加命名导出https://github.com/styled-components/styled-components/issues/1654