不能使用webpack构建

时间:2016-12-12 10:42:35

标签: webpack

我有一个使用fountainjs.io yo生成器生成的应用程序。尝试构建

时出现以下错误

描述

错误消息&堆栈跟踪

[09:23:51] Loading /Users/calvin/dev/hospitalMap/gulp_tasks/browsersync.js
[09:23:52] Loading /Users/calvin/dev/hospitalMap/gulp_tasks/karma.js
[09:23:54] Loading /Users/calvin/dev/hospitalMap/gulp_tasks/misc.js
[09:23:55] Loading /Users/calvin/dev/hospitalMap/gulp_tasks/webpack.js
[09:23:56] Using gulpfile ~/dev/hospitalMap/gulpfile.js
[09:23:56] Starting 'build'...
[09:23:56] Starting 'other'...
[09:23:56] Starting 'webpack:dist'...
[09:24:01] Finished 'other' after 4.82 s
[09:24:24] Time: 27381ms
                         Asset     Size  Chunks       Chunk Names
vendor-794d775dfd6b685d2497.js  1.34 MB       0       vendor

ERROR in Entry module not found: Error: Can't resolve 'babel' in '/Users/calvin/dev/hospitalMap'

ERROR in ./~/mime/mime.js
Module not found: Error: Can't resolve 'fs' in '/Users/calvin/dev/hospitalMap/node_modules/mime'
 @ ./~/mime/mime.js 2:9-22
 @ ./~/url-loader/index.js
 @ multi vendor
Child html-webpack-plugin for "index.html":
         Asset    Size  Chunks       Chunk Names
    index.html  2.9 kB       0
[09:24:24] Finished 'webpack:dist' after 28 s
[09:24:24] Finished 'build' after 28 s

喷泉生成器配置

{
  "generator-fountain-angular1": {
    "version": "1.0.0-rc1",
    "props": {
      "framework": "angular1",
      "modules": "webpack",
      "js": "babel",
      "ci": [],
      "css": "scss",
      "resolved": "/usr/local/lib/node_modules/generator-fountain-webapp/node_modules/generator-fountain-angular1/generators/app/index.js",
      "namespace": "fountain-angular1",
      "argv": {
        "remain": [],
        "cooked": [],
        "original": []
      },
      "sample": "hello",
      "router": "uirouter"
    }
  }
}

环境

Node.js v7.2.1

darwin 16.1.0

哟1.8.5

npm 3.10.10

1 个答案:

答案 0 :(得分:0)

您正在使用来自npm的mime,它使用fsfs是一个仅限节点的程序包,无法通过webpack在浏览器中运行。如果您将mime上的依赖项替换为经验证可在浏览器中使用的依赖项,那么您应该没问题。