错误阅读webpack-stats.json。您确定WebPack已生成文件并且路径正确吗?
我与Vue一起安装了Django,并在运行时获得了此EROR:
Error reading webpack-stats.json. Are you sure webpack has generated the file and the path is correct?
vue create frontend
cd frontend
npm run serve
babel.config.js
jsconfig.json
node_modules
package.json
package-lock.json
public
README.md
src
vue.config.js
npm --version
nodejs --version
node --version
.17.6└──
npm list webpack-bundle-tracker
pip install django-webpack-loader
pip freeze
ango-webpack-loader == 1.5.0
INSTALLED_APPS = (
...
'webpack_loader',
...
)
# vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true
})
index.html
{% load render_bundle from webpack_loader %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title></title>
{% render_bundle 'app' 'css' %}
</head>
<body>
<div class="main">
<main>
<div id="app">
</div>
{% endblock %}
</main>
</div>
{% render_bundle 'app' 'js' %}
</body>
</html>
I installed django with Vue and got this eror in runtime:
Error reading webpack-stats.json. Are you sure webpack has generated the file and the path is correct?
alongside manage.py:
vue create frontend
Default ([Vue 3] babel, eslint)
cd frontend
npm run serve
list of files in frontend directory is:
babel.config.js
jsconfig.json
node_modules
package.json
package-lock.json
public
README.md
src
vue.config.js
npm --version
6.14.15
nodejs --version
v10.19.0
node --version
v14.17.6
npm list webpack-bundle-tracker
pip install django-webpack-loader
pip freeze
django-webpack-loader==1.5.0
INSTALLED_APPS = (
...
'webpack_loader',
...
)
# vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true
})
index.html
{% load render_bundle from webpack_loader %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title></title>
{% render_bundle 'app' 'css' %}
</head>
<body>
<div class="main">
<main>
<div id="app">
</div>
{% endblock %}
</main>
</div>
{% render_bundle 'app' 'js' %}
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文件结构是:
我也运行
npm运行构建
npm运行服务settings.py:
files structure are:
also i run
npm run build
beforenpm run serve
settings.py:
您需要导入并添加
webpack-bundle-tracker
插件vue.config.js
:You need to import and add the
webpack-bundle-tracker
plugin invue.config.js
: