javascript - Webpack:找不到 bundle.js

标签 javascript node.js webpack

我终于让他的开发服务器运行起来了,我在屏幕上看到了一些东西。 我已经为 NPM 设置了一个“启动”脚本,如下所示:

"start": "webpack-dev-server --content-base app"

我得到一个错误:

http://localhost:8080/bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)

我的文件夹设置如下:

appDir
  ->app
  ->node_modules
  webpack.config.js
  package.json

我的 webpack.config.js:

module.exports = {
    context: __dirname + '/app',
    entry: './index.js',
    output: {
        path: __dirname + '/app',
        filename: './bundle.js'
    }
}

你能告诉我哪里出了问题吗?

最佳答案

bundle.js 位于您的 /app 目录中。输出中的 path 选项指定文件所在的绝对路径。

此外,您不需要文件名中的 ./。它将相对于 output.path 得到解决,但它令人困惑并且可能导致了您的问题。

关于javascript - Webpack:找不到 bundle.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29923277/

相关文章:

javascript - 颜色在 sectionList 上保持随机化

javascript - 如何在单个查询中更新多行数据?

javascript - 连接到我的 Visual Studio Online API 返回 HTTP 302

javascript - NodeJS ES6 模块和 "default"导出/导入

linux - Angular-CLI 在构建时卡住

javascript - 如何使用.click在同一个DOM对象上setInterval和clearInterval?

javascript - 如何使用谷歌脚本在字符串中查找文本?

javascript - Jasmine-node - 在其他函数内部调用的构造函数上创建 spy

node.js - 使用mocha和chai进行后端单元测试,如何在每次测试前清除数据库

reactjs - 如何在 React、ES6、Electron 应用程序上使用 native 节点模块?