我正在尝试测试一个自定义的Webpack配置。我读到过,我可以使用npx webpack而不是node ./node_modules/webpack/bin/webpack.js。但我似乎不能让它工作。
user@comp:~/raw> npx webpack
The CLI moved into a separate package: webpack-cli.
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D当我切换到运行npx webpack-cli时,我得到一个不同的错误:
user@comp:~/> npx webpack-cli
npx: installed 489 in 19.186s
Cannot find module 'webpack'发布于 2018-04-01 15:30:58
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D基本上就是这样。在安装了webpack-cli之后,只需使用
npx webpack发布于 2018-04-01 15:56:18
你可以全局安装webpack和webpack-cli包,这样你就不需要使用node ./path/to/webpack了:
$ npm install webpack webpack-cli -g这将在您的计算机上全局安装webpack。然后在您的项目文件夹中运行
$ webpack发布于 2018-04-04 00:42:23
我听从了其他答案中的建议,在全球范围内为npm install webpack webpack-cli -g安装了Webpack。
当我运行npx webpack时,我得到了
No configuration file found and no output filename configured via CLI option.
A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options.这时我意识到我不在项目文件夹中...
https://stackoverflow.com/questions/49595553
复制相似问题