执行webpack -v命令总是提示安装webpack-cli
程序员文章站
2022-05-31 20:22:40
...
执行webpack -v命令总是提示安装webpack-cli
在我们安装Node.js之后安装webpack打包工具后,想要查看webpack的版本号,在cmd中输入webpack -v
显示让我们安装webpack-cli
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
- webpack-cli (https://github.com/webpack/webpack-cli)
The original webpack full-featured CLI.
We will use "npm" to install the CLI via "npm install -D".
Do you want to install 'webpack-cli' (yes/no):
此时我们选择yes后他会帮我们安装webpack-cli,但是安装完成后再次使用webpack -v命令去查看版本号时依然出现让你安装webpack-cli的提示
解决方案
查看是否全局安装webpcak和webpack-cli
这里我们选择yes之后还是不行,问题出在安装webpack的时候是选择的全局安装,这里的webpack-cli也要选择全局安装
npm install --save-dev webpack-cli -g