我在使用Ruby Rails的React v17,收到如下错误:找不到模块
'\jsx\node_modules\react\jsx-runtime' imported from \jsx\index.mjs Did you mean to import react/jsx-runtime.j
正如在教程中提到的,进入下面的解决方案是不工作的,我修改了app/javascript/。storybook/webpack。配置ts:
config.resolve.alias= {
...config.resolve.alias,
"react/jsx-dev-runtime": "react/jsx-dev-runtime.js",
"react/jsx-runtime": "react/jsx-runtime.js"
}
仍然得到错误:
ERROR in ./node_modules/@ezgrid/grid-react/lib/react/ReactDataGrid.js 2:0-56
Module not found: Error: Can't resolve 'react/jsx-runtime' in '/home/Projects/huddle/node_modules/@ezgrid/grid-react/lib/react'
Did you mean 'jsx-runtime.js'?
BREAKING CHANGE: The request 'react/jsx-runtime' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
“谁能帮帮我?”我不知道到底哪里出了问题。**
我尝试修改webpack。通过添加以下代码配置.ts:
config.resolve.alias= {
...config.resolve.alias,
"react/jsx-dev-runtime": "react/jsx-dev-runtime.js",
"react/jsx-runtime": "react/jsx-runtime.js"
}
它不工作,可能我把代码放在错误的文件中。任何人都可以帮助我找到正确的webpack配置文件。
1条答案
按热度按时间mnowg1ta1#
您的思路是正确的-解决方案是设置配置解析
还有几件事你可以尝试:
如果你看到一个错误,给你的路径,它试图使用,这意味着你已经修改了正确的webpack文件。如果不完全了解项目的结构,很难说webpack文件位于哪里。如果您有订阅,您可以随时联系我们的支持团队。
更多信息:http://reactdatagrid.com/docs/intro