不能在require.ensure中使用变量,这是正常的吗?

时间:2016-08-25 05:14:00

标签: webpack

Win10 64,webpack.config.js

var webpack = require("webpack");

module.exports = {
    entry: "./index.js",
    output: {
        path: '../wdksw/static/js',
        publicPath: '/static/js/', 
        filename: "a.js", 
    },
    plugins: [
        new webpack.ProvidePlugin({$:'jquery', jQuery:'jquery'}), 
    ], 
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" }, 
            { test: /\.scss$/, loaders: ["style", "css", "sass"]}, 
            { test: /\.coffee$/, loader: "coffee-loader" },
        ], 

    }
};

index.js,没关系:

require.ensure(['./test'], function(require) {
    require('./test');
});

但这会引起错误:

var paths='./test';
require.ensure([paths], function(require) {
    require(paths);
});

错误:

Hash: 3965c2d3b84f8dcdb6d4
Version: webpack 1.13.2
Time: 7766ms
Asset     Size  Chunks             Chunk Names
 a.js  3.29 MB       0  [emitted]  main
   [0] ./index.js 1.5 kB {0} [built]
   [5] . ^\.\/.*$ 1.05 kB {0} [built] [6 warnings]
   [6] ./README.md 0 bytes [optional] [built] [failed]
   [7] ./aa.js 661 bytes {0} [optional] [built]
  [19] ./css/main.css.map 0 bytes [optional] [built] [failed]
  [26] ./jarsj.js 895 bytes {0} [optional] [built]
 [389] ./js/moxie.js 387 kB {0} [built]
 [390] ./js/node-plupload.js 279 kB {0} [optional] [built]
 [391] ./js/plupload.js 81 kB {0} [built]
 [392] ./js/plupload.full.min.js 109 kB {0} [optional] [built]
 [393] ./js/qiniu.js 60.1 kB {0} [built]
 [394] ./js/raw/moxie.js 387 kB {0} [optional] [built]
 [395] ./js/raw/plupload.js 81 kB {0} [optional] [built]
 [396] ./js/raw/qiniu.js 60.1 kB {0} [optional] [built]
 [397] ./js/router.js 806 bytes {0} [optional] [built]
 [398] ./js ^\.\/.*$ 514 bytes {0} [built]
 [399] ./js/uploader.js 2.9 kB {0} [optional] [built]
 [406] ./npm-debug.log 0 bytes [optional] [built] [failed]
 [407] ./package.json 0 bytes [optional] [built] [failed]
 [408] ./test.js 29 bytes {0} [optional] [built]
 [409] ./webpack.config.js 895 bytes {0} [optional] [built]
    + 389 hidden modules

WARNING in ./index.js
Critical dependencies:
55:1-8 require function is used in a way in which dependencies cannot be statically extracted
 @ ./index.js 55:1-8

WARNING in . ^\.\/.*$
Module not found: Error: a dependency to an entry point is not allowed
 @ . ^\.\/.*$

WARNING in . ^\.\/.*$
Module not found: Error: a dependency to an entry point is not allowed
 @ . ^\.\/.*$

WARNING in ./package.json
Module parse failed: C:\projects\pack\package.json Unexpected token (2:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:8)
    at Parser.pp$4.raise (C:\projects\pack\node_modules\acorn\dist\acorn.js:2221:15)
    at Parser.pp.unexpected (C:\projects\pack\node_modules\acorn\dist\acorn.js:603:10)
    at Parser.pp.semicolon (C:\projects\pack\node_modules\acorn\dist\acorn.js:581:61)
    at Parser.pp$1.parseExpressionStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:966:10)
    at Parser.pp$1.parseStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:730:24)
    at Parser.pp$1.parseBlock (C:\projects\pack\node_modules\acorn\dist\acorn.js:981:25)
    at Parser.pp$1.parseStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:709:33)
    at Parser.pp$1.parseTopLevel (C:\projects\pack\node_modules\acorn\dist\acorn.js:638:25)
    at Parser.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:516:17)
    at Object.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:3098:39)
    at Parser.parse (C:\projects\pack\node_modules\webpack\lib\Parser.js:902:15)
    at DependenciesBlock.<anonymous> (C:\projects\pack\node_modules\webpack\lib\NormalModule.js:104:16)
    at DependenciesBlock.onModuleBuild (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
    at nextLoader (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
    at C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
    at Storage.provide (C:\projects\pack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:52:20)
    at CachedInputFileSystem.readFile (C:\projects\pack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:140:24)
    at DependenciesBlock.onLoadPitchDone (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:255:7)
    at DependenciesBlock.loadPitch (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:182:27)
    at DependenciesBlock.doBuild (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:241:4)
    at DependenciesBlock.build (C:\projects\pack\node_modules\webpack\lib\NormalModule.js:84:14)
    at Compilation.buildModule (C:\projects\pack\node_modules\webpack\lib\Compilation.js:126:9)
    at C:\projects\pack\node_modules\webpack\lib\Compilation.js:309:10
    at C:\projects\pack\node_modules\webpack\lib\NormalModuleFactory.js:58:13
    at NormalModuleFactory.applyPluginsAsyncWaterfall (C:\projects\pack\node_modules\tapable\lib\Tapable.js:75:69)
    at onDoneResolving (C:\projects\pack\node_modules\webpack\lib\NormalModuleFactory.js:38:11)
    at onDoneResolving (C:\projects\pack\node_modules\webpack\lib\NormalModuleFactory.js:121:6)
    at C:\projects\pack\node_modules\webpack\lib\NormalModuleFactory.js:116:7
    at C:\projects\pack\node_modules\async\lib\async.js:726:13
    at C:\projects\pack\node_modules\async\lib\async.js:52:16
 @ . ^\.\/.*$

WARNING in ./README.md
Module parse failed: C:\projects\pack\README.md Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '#' (1:0)
    at Parser.pp$4.raise (C:\projects\pack\node_modules\acorn\dist\acorn.js:2221:15)
    at Parser.pp$7.getTokenFromCode (C:\projects\pack\node_modules\acorn\dist\acorn.js:2756:10)
    at Parser.pp$7.readToken (C:\projects\pack\node_modules\acorn\dist\acorn.js:2477:17)
    at Parser.pp$7.nextToken (C:\projects\pack\node_modules\acorn\dist\acorn.js:2468:15)
    at Parser.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:515:10)
    at Object.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:3098:39)
    at Parser.parse (C:\projects\pack\node_modules\webpack\lib\Parser.js:902:15)
    at DependenciesBlock.<anonymous> (C:\projects\pack\node_modules\webpack\lib\NormalModule.js:104:16)
    at DependenciesBlock.onModuleBuild (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
    at nextLoader (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
    at C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
    at Storage.finished (C:\projects\pack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
    at C:\projects\pack\node_modules\graceful-fs\graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
 @ . ^\.\/.*$

WARNING in ./aa.js
Critical dependencies:
17:16-23 require function is used in a way in which dependencies cannot be statically extracted
 @ ./aa.js 17:16-23

WARNING in ./css/main.css.map
Module parse failed: C:\projects\pack\css\main.css.map Unexpected token (2:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:9)
  at Parser.pp$4.raise (C:\projects\pack\node_modules\acorn\dist\acorn.js:2221:15)
  at Parser.pp.unexpected (C:\projects\pack\node_modules\acorn\dist\acorn.js:603:10)
  at Parser.pp.semicolon (C:\projects\pack\node_modules\acorn\dist\acorn.js:581:61)
  at Parser.pp$1.parseExpressionStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:966:10)
  at Parser.pp$1.parseStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:730:24)
  at Parser.pp$1.parseBlock (C:\projects\pack\node_modules\acorn\dist\acorn.js:981:25)
  at Parser.pp$1.parseStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:709:33)
  at Parser.pp$1.parseTopLevel (C:\projects\pack\node_modules\acorn\dist\acorn.js:638:25)
  at Parser.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:516:17)
  at Object.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:3098:39)
  at Parser.parse (C:\projects\pack\node_modules\webpack\lib\Parser.js:902:15)
  at DependenciesBlock.<anonymous> (C:\projects\pack\node_modules\webpack\lib\NormalModule.js:104:16)
  at DependenciesBlock.onModuleBuild (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
  at nextLoader (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
  at C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
  at Storage.finished (C:\projects\pack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
  at C:\projects\pack\node_modules\graceful-fs\graceful-fs.js:78:16
  at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

 @ . ^\.\/.*$

WARNING in ./js/router.js
Critical dependencies:
8:20-27 require function is used in a way in which dependencies cannot be statically extracted
14:20-27 require function is used in a way in which dependencies cannot be statically extracted
 @ ./js/router.js 8:20-27 14:20-27

WARNING in ./npm-debug.log
Module parse failed: C:\projects\pack\npm-debug.log Unexpected token (1:2)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:2)
  at Parser.pp$4.raise (C:\projects\pack\node_modules\acorn\dist\acorn.js:2221:15)
  at Parser.pp.unexpected (C:\projects\pack\node_modules\acorn\dist\acorn.js:603:10)
  at Parser.pp.semicolon (C:\projects\pack\node_modules\acorn\dist\acorn.js:581:61)
  at Parser.pp$1.parseExpressionStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:966:10)
  at Parser.pp$1.parseStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:730:24)
  at Parser.pp$1.parseTopLevel (C:\projects\pack\node_modules\acorn\dist\acorn.js:638:25)
  at Parser.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:516:17)
  at Object.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:3098:39)
  at Parser.parse (C:\projects\pack\node_modules\webpack\lib\Parser.js:902:15)
  at DependenciesBlock.<anonymous> (C:\projects\pack\node_modules\webpack\lib\NormalModule.js:104:16)
  at DependenciesBlock.onModuleBuild (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
  at nextLoader (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
  at C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
  at Storage.finished (C:\projects\pack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
  at C:\projects\pack\node_modules\graceful-fs\graceful-fs.js:78:16
  at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

 @ . ^\.\/.*$

WARNING in ./~/chokidar/lib/fsevents-handler.js
Module not found: Error: Cannot resolve module 'fsevents' in C:\projects\pack\node_modules\chokidar\lib
 @ ./~/chokidar/lib/fsevents-handler.js 7:17-36

ERROR in ./~/css-loader!./~/sass-loader!./css/base.scss
Module build failed:
      background: $LINK_HOVER_COLOR;
                 ^
      Undefined variable: "$LINK-HOVER-COLOR".
      in C:\projects\pack\css\base.scss (line 25, column 19)
 @ ./css/base.scss 4:14-115

ERROR in ./~/css-loader!./~/sass-loader!./css/layout.scss
Module build failed:
  background: $SOLO_BUTTON_COLOR;
             ^
      Undefined variable: "$SOLO-BUTTON-COLOR".
      in C:\projects\pack\css\layout.scss (line 93, column 15)
 @ ./css/layout.scss 4:14-117

ERROR in ./~/css-loader!./~/sass-loader!./css/input.scss
Module build failed:
    border: 0px solid $MAIN_COLOR;  /*IE 6/7/8*/
                     ^
      Undefined variable: "$MAIN-COLOR".
      in C:\projects\pack\css\input.scss (line 42, column 23)
 @ ./css/input.scss 4:14-116

ERROR in ./~/css-loader!./~/sass-loader!./css/tip.scss
Module build failed:
  @include base($ERROR_COLOR);
               ^
      Undefined variable: "$ERROR-COLOR".
      in C:\projects\pack\css\tip.scss (line 30, column 17)
 @ ./css/tip.scss 4:14-114

ERROR in ./~/css-loader!./~/sass-loader!./css/nav.scss
Module build failed:
@mixin base($height:$NAVBAR_HEIGHT, $color:$NAVBAR_HOVER_COLOR, $display:inline-block) {
                   ^
      Undefined variable: "$NAVBAR-HEIGHT".
      in C:\projects\pack\css\nav.scss (line 1, column 21)
 @ ./css/nav.scss 4:14-114

ERROR in (webpack)/package.json
Module parse failed: C:\projects\pack\node_modules\webpack\package.json Unexpected token (2:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:9)
  at Parser.pp$4.raise (C:\projects\pack\node_modules\acorn\dist\acorn.js:2221:15)
  at Parser.pp.unexpected (C:\projects\pack\node_modules\acorn\dist\acorn.js:603:10)
  at Parser.pp.semicolon (C:\projects\pack\node_modules\acorn\dist\acorn.js:581:61)
  at Parser.pp$1.parseExpressionStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:966:10)
  at Parser.pp$1.parseStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:730:24)
  at Parser.pp$1.parseBlock (C:\projects\pack\node_modules\acorn\dist\acorn.js:981:25)
  at Parser.pp$1.parseStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:709:33)
  at Parser.pp$1.parseTopLevel (C:\projects\pack\node_modules\acorn\dist\acorn.js:638:25)
  at Parser.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:516:17)
  at Object.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:3098:39)
  at Parser.parse (C:\projects\pack\node_modules\webpack\lib\Parser.js:902:15)
  at DependenciesBlock.<anonymous> (C:\projects\pack\node_modules\webpack\lib\NormalModule.js:104:16)
  at DependenciesBlock.onModuleBuild (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
  at nextLoader (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
  at C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
  at Storage.provide (C:\projects\pack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:52:20)
  at CachedInputFileSystem.readFile (C:\projects\pack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:140:24)
  at DependenciesBlock.onLoadPitchDone (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:255:7)
  at DependenciesBlock.loadPitch (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:182:27)
  at DependenciesBlock.doBuild (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:241:4)
  at DependenciesBlock.build (C:\projects\pack\node_modules\webpack\lib\NormalModule.js:84:14)
  at Compilation.buildModule (C:\projects\pack\node_modules\webpack\lib\Compilation.js:126:9)
  at C:\projects\pack\node_modules\webpack\lib\Compilation.js:309:10
  at C:\projects\pack\node_modules\webpack\lib\NormalModuleFactory.js:58:13
  at NormalModuleFactory.applyPluginsAsyncWaterfall (C:\projects\pack\node_modules\tapable\lib\Tapable.js:75:69)
  at onDoneResolving (C:\projects\pack\node_modules\webpack\lib\NormalModuleFactory.js:38:11)
  at onDoneResolving (C:\projects\pack\node_modules\webpack\lib\NormalModuleFactory.js:121:6)
  at C:\projects\pack\node_modules\webpack\lib\NormalModuleFactory.js:116:7
  at C:\projects\pack\node_modules\async\lib\async.js:726:13
  at C:\projects\pack\node_modules\async\lib\async.js:52:16
  at async.forEachOf.async.eachOf (C:\projects\pack\node_modules\async\lib\async.js:236:30)
  at _parallel (C:\projects\pack\node_modules\async\lib\async.js:717:9)
  at Object.async.parallel (C:\projects\pack\node_modules\async\lib\async.js:731:9)
  at C:\projects\pack\node_modules\webpack\lib\NormalModuleFactory.js:109:12
  at C:\projects\pack\node_modules\async\lib\async.js:726:13
  at C:\projects\pack\node_modules\async\lib\async.js:52:16
  at done (C:\projects\pack\node_modules\async\lib\async.js:246:17)
  at C:\projects\pack\node_modules\async\lib\async.js:44:16
  at C:\projects\pack\node_modules\async\lib\async.js:723:17
  at C:\projects\pack\node_modules\async\lib\async.js:167:37
  at C:\projects\pack\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:29:4
  at onResolved (C:\projects\pack\node_modules\enhanced-resolve\lib\Resolver.js:39:10)
  at C:\projects\pack\node_modules\enhanced-resolve\lib\Resolver.js:123:21
  at C:\projects\pack\node_modules\enhanced-resolve\lib\Resolver.js:191:15
  at applyPluginsParallelBailResult.createInnerCallback.log (C:\projects\pack\node_modules\enhanced-resolve\lib\Resolver.js:104:30)
  at loggingCallbackWrapper (C:\projects\pack\node_modules\enhanced-resolve\lib\createInnerCallback.js:21:19)
  at C:\projects\pack\node_modules\tapable\lib\Tapable.js:134:6
  at innerCallback (C:\projects\pack\node_modules\enhanced-resolve\lib\Resolver.js:90:37)
  at loggingCallbackWrapper (C:\projects\pack\node_modules\enhanced-resolve\lib\createInnerCallback.js:21:19)
  at C:\projects\pack\node_modules\tapable\lib\Tapable.js:134:6
  at Tapable.<anonymous> (C:\projects\pack\node_modules\enhanced-resolve\lib\ResultSymlinkPlugin.js:39:32)
  at C:\projects\pack\node_modules\enhanced-resolve\lib\Resolver.js:191:15
  at C:\projects\pack\node_modules\enhanced-resolve\lib\ResultSymlinkPlugin.js:36:5
  at Storage.finished (C:\projects\pack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
  at FSReqWrap.oncomplete (fs.js:82:15)

 @ (webpack)/lib/Stats.js 139:16-42

ERROR in ./~/uglify-js/tools/node.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\uglify-js\tools
 @ ./~/uglify-js/tools/node.js 8:9-22

ERROR in (webpack)/lib/node/NodeMainTemplateAsync.runtime.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\webpack\lib\node
 @ (webpack)/lib/node/NodeMainTemplateAsync.runtime.js 9:2-15 24:2-15

ERROR in (webpack)/lib/node/OldNodeWatchFileSystem.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\webpack\lib\node
 @ (webpack)/lib/node/OldNodeWatchFileSystem.js 5:9-22

ERROR in (webpack)/lib/node/NodeOutputFileSystem.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\webpack\lib\node
 @ (webpack)/lib/node/NodeOutputFileSystem.js 5:9-22

ERROR in ./~/mkdirp/index.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\mkdirp
 @ ./~/mkdirp/index.js 2:9-22

ERROR in ./~/graceful-fs/graceful-fs.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\graceful-fs
 @ ./~/graceful-fs/graceful-fs.js 1:9-22

ERROR in ./~/graceful-fs/fs.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\graceful-fs
 @ ./~/graceful-fs/fs.js 3:9-22

ERROR in ./~/constants-browserify/constants.json
Module parse failed: C:\projects\pack\node_modules\constants-browserify\constants.json Unexpected token (2:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:12)
  at Parser.pp$4.raise (C:\projects\pack\node_modules\acorn\dist\acorn.js:2221:15)
  at Parser.pp.unexpected (C:\projects\pack\node_modules\acorn\dist\acorn.js:603:10)
  at Parser.pp.semicolon (C:\projects\pack\node_modules\acorn\dist\acorn.js:581:61)
  at Parser.pp$1.parseExpressionStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:966:10)
  at Parser.pp$1.parseStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:730:24)
  at Parser.pp$1.parseBlock (C:\projects\pack\node_modules\acorn\dist\acorn.js:981:25)
  at Parser.pp$1.parseStatement (C:\projects\pack\node_modules\acorn\dist\acorn.js:709:33)
  at Parser.pp$1.parseTopLevel (C:\projects\pack\node_modules\acorn\dist\acorn.js:638:25)
  at Parser.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:516:17)
  at Object.parse (C:\projects\pack\node_modules\acorn\dist\acorn.js:3098:39)
  at Parser.parse (C:\projects\pack\node_modules\webpack\lib\Parser.js:902:15)
  at DependenciesBlock.<anonymous> (C:\projects\pack\node_modules\webpack\lib\NormalModule.js:104:16)
  at DependenciesBlock.onModuleBuild (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
  at nextLoader (C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
  at C:\projects\pack\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
  at Storage.finished (C:\projects\pack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
  at C:\projects\pack\node_modules\graceful-fs\graceful-fs.js:78:16
  at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

 @ ./~/graceful-fs/polyfills.js 2:16-36

ERROR in ./~/chokidar/index.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\chokidar
 @ ./~/chokidar/index.js 3:9-22

ERROR in ./~/chokidar/lib/nodefs-handler.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\chokidar\lib
 @ ./~/chokidar/lib/nodefs-handler.js 3:9-22

ERROR in ./~/chokidar/lib/fsevents-handler.js
Module not found: Error: Cannot resolve module 'fs' in C:\projects\pack\node_modules\chokidar\lib
 @ ./~/chokidar/lib/fsevents-handler.js 3:9-22

1 个答案:

答案 0 :(得分:1)

无法require.ensure中执行动态需求,因为webpack必须在构建阶段(创建数据块所需)静态进行分析。

您的错误表明您有上述问题。

55:1-8 require function is used in a way in which dependencies cannot be statically extracted