【问题标题】:Trouble Installing React as an App within Django在 Django 中将 React 作为应用程序安装时遇到问题
【发布时间】:2019-09-07 20:26:53
【问题描述】:

我正在使用本教程使用 Django 内置的 API 为前端安装 React。

https://sweetcode.io/how-use-djang-react-ap/

到目前为止,我的这个项目的存储库在这里:

https://github.com/AlexMercedCoder/DjangoReactCRM

我在教程中通过运行“npm run dev”安装 react

这是我得到的错误,没有修改相关文件页面似乎可以解决它:

> webpack --mode development ./frontend/src/components/index.jsx --output 
./frontend/static/frontend/main.js


Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.

Hash: 097c83a63f327afef15a
Version: webpack 4.39.3
Time: 80ms
Built at: 09/07/2019 4:16:05 PM

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.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\alexm\AppData\Roaming\npm-cache\_logs\2019-09- 
07T20_16_05_497Z-debug.log

【问题讨论】:

    标签: django reactjs django-rest-framework


    【解决方案1】:

    如错误所述,您的项目中没有名为 ./frontend/src/components/index.jsx 的文件 - https://github.com/AlexMercedCoder/DjangoReactCRM/tree/master/frontend/src/components。它是index.js

    因此,在您的 package.json 中,将脚本更改为:

    webpack --mode development ./frontend/src/components/index.js --output ./frontend/static/frontend/main.js
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-24
      • 2020-08-07
      • 1970-01-01
      • 1970-01-01
      • 2011-11-27
      • 1970-01-01
      • 2015-09-09
      相关资源
      最近更新 更多