我用“create-react-app”创建了一个项目。我已经通过弹出它并在 webpack 配置中使用别名将 preact 添加到项目中。
alias: {
'react': 'preact-compat-enzyme',
'react-dom': 'preact-compat-enzyme',
'react-dom/server': 'preact-render-to-string',
'react-addons-test-utils': 'preact-test-utils',
'react-addons-transition-group': 'preact-transition-group'
}
这在代码中有效,我能够呈现应用程序。但是,在测试中我收到以下错误
Cannot find module 'react' from 'App.test.js'
为什么找不到模块?除了别名之外,我们还有什么需要添加到配置中的吗?