問題:在 Django 中將 React 作為應用程序安裝時遇到問題出現以下錯誤
ERROR in Entry module not found: Error: Can't resolve
'./frontend/src/components/index.jsx' in
'C:\Users\alexm\projects\DjangoReactCRM\drcrm'
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! drcrm@1.0.0 dev: `webpack ‑‑mode development
./frontend/src/components/index.jsx ‑‑output
./frontend/static/frontend/main.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the drcrm@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
解決方式:
As the error states, you don't have a file called ./frontend/src/components/index.jsx in your project ‑ https://github.com/AlexMercedCoder/DjangoReactCRM/tree/master/frontend/src/components. It is index.js instead.
So, in your package.json, change the script to be:
webpack ‑‑mode development ./frontend/src/components/index.js ‑‑output ./frontend/static/frontend/main.js