webpack 命令打包出错

$ webpack ./src/page/index.js ./dist/app.js



C:\Users\iuyiy\desktop\mall\webpack.config.js:2

    entry: './src/page/index/index.js',

                                      ^


SyntaxError: Invalid or unexpected token

    at NativeCompileCache._moduleCompile (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\           v8-compile-cache\v8-compile-cache.js:226:18)

    at Module._compile (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\v8-compile-cache\v           8-compile-cache.js:172:36)

    at Object.Module._extensions..js (module.js:663:10)

    at Module.load (module.js:565:32)

    at tryModuleLoad (module.js:505:12)

    at Function.Module._load (module.js:497:3)

    at Module.require (module.js:596:17)

    at require (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\v8-compile-cache\v8-compil           e-cache.js:159:20)

    at WEBPACK_OPTIONS (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\bin\convert-argv.js:133:13)

    at requireConfig (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\bin\convert-argv.js:135:6)

    at C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\bin\convert-argv.js:142:17

    at Array.forEach (<anonymous>)

    at module.exports (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\bin\convert-argv.js:140:15)

    at yargs.parse (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\bin\webpack.js:239:39)

    at Object.parse (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\yargs\yargs.js:543:18           )

    at C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\bin\webpack.js:217:8

    at Object.<anonymous> (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack-cli\bin\webpack.js:512:3)

    at Module._compile (module.js:652:30)

    at Object.Module._extensions..js (module.js:663:10)

    at Module.load (module.js:565:32)

    at tryModuleLoad (module.js:505:12)

    at Function.Module._load (module.js:497:3)

    at Module.require (module.js:596:17)

    at require (internal/module.js:11:18)

    at Object.<anonymous> (C:\Users\iuyiy\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:12:2)

    at Module._compile (module.js:652:30)

    at Object.Module._extensions..js (module.js:663:10)

    at Module.load (module.js:565:32)

    at tryModuleLoad (module.js:505:12)

    at Function.Module._load (module.js:497:3)


无悔欲
浏览 3610回答 3
3回答

lily001

注意: - 输出需要明确指定。所以改为--webpack ./src/page/index/index.js --output ./dist/app.js --mode development

慕运维5913954

我刚刚也遇到了这个问题,应该是webpack版本太高了,1.15.0版本用webpack ./src/page/index.js ./dist/app.js这个命令就可以,4.17.1版本就不行了,就需要用楼上说的webpack ./src/page/index/index.js --output ./dist/app.js --mode development

西兰花伟大炮

你entry是不是多写了个index
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Node.js