我试图进口Ammo物理引擎到反应-巴比伦项目,建立与CRA。我不断得到填充错误:
Compiled with problems:X
ERROR in ./node_modules/ammo.js/builds/ammo.js 207:22-45
Module not found: Error: Can't resolve 'path' in 'C:\...\node_modules\ammo.js\builds'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
ERROR in ./node_modules/ammo.js/builds/ammo.js 210:18-31
Module not found: Error: Can't resolve 'fs' in 'C:\...\node_modules\ammo.js\builds'使用导入的组件如下所示:
//@ts-ignore
import { default as Ammo } from 'ammo.js/builds/ammo';
Ammo();
...
<Scene enablePhysics={[gravity, new AmmoJSPlugin(false, Ammo())]}>我认为问题来自WASM编译,但我完全不知道如何解决它。如果可能的话,我宁愿不弹出CRA。
发布于 2022-03-04 10:16:09
您必须使用@craco/craco覆盖webpack配置
https://stackoverflow.com/questions/70671677
复制相似问题