webpack hello.js hello.bundle.js 报错

来源:1-2 Webpack 安装和命令行

慕容2428546

2021-09-28 00:04


$ webpack hello.js hello.bundle.js

C:\Users\yu\AppData\Roaming\npm\node_modules\webpack-cli\bin\cli.js:244

                                throw err;

                                ^


TypeError: Cannot read property 'length' of undefined

    at processConfiguredOptions (C:\Users\yu\AppData\Roaming\npm\node_modules\webpack-cli\bin\convert-argv.js:160:44)

    at module.exports (C:\Users\yu\AppData\Roaming\npm\node_modules\webpack-cli\bin\convert-argv.js:148:10)

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

    at Object.parse (C:\Users\yu\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\_yargs@11.1.0@yargs\yargs.js:552:18)

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

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

    at Module._compile (internal/modules/cjs/loader.js:778:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

    at Module.load (internal/modules/cjs/loader.js:653:32)

    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

    at Module.require (internal/modules/cjs/loader.js:692:17)

    at require (internal/modules/cjs/helpers.js:25:18)

    at runCli (C:\Users\yu\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:54:2)

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

    at Module._compile (internal/modules/cjs/loader.js:778:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

    at Module.load (internal/modules/cjs/loader.js:653:32)

    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)

    at startup (internal/bootstrap/node.js:283:19)

    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)


写回答 关注

2回答

  • weixin_慕斯1009030
    2021-11-16 22:18:34

     webpack ./hello.js --output-path ./ --output-filename bundle.js --mode development

    搜索

    复制

    qq_甲骨文...

    你好,能否请教一下Error: Unknown option '--module-bind'这个如果要转换成新语法的方法,我搜索了半天都没找到

    2022-01-17 17:53:54

    共 2 条回复 >

  • 慕侠253528
    2021-10-23 15:17:40
    webpack新版本不支持,建议在目录下加个webpack.config.js文件
    const path = require('path');module.exports = {  entry: './hello.js',  mode: 'development',  output: {    filename: 'hello.bundle.js',    path: path.resolve(__dirname)  },};
    
    然后运行 webpack就可以了


webpack深入与实战

webpack实战教程,用真实项目带你探索 webpack 强大的功能

86561 学习 · 721 问题

查看课程

相似问题