webpack 不是内部或外部命令,也不是可运行的程序或批处理文件 [英] webpack is not recognized as a internal or external command,operable program or batch file
问题描述
我正在学习 React.js,我使用的是 Windows 8 操作系统.我已经导航到我的根文件夹
I am Learning React.js and i am using windows 8 OS.i have navigate to my root folder
1.Created the package.json file by npm init
2. install webpack by npm install -S webpack.now webpack has been downloaded to my modules folder
3. install webpack globally by typing npm install webpack -g
4. i am also having a webpack.config.js in my root folder which contains the source and ouput directory
5. when i type the webpack command i am getting the below error.
webpack 未被识别为内部或外部命令、可运行的程序或批处理文件
推荐答案
我也遇到这个问题很久了.(webpack 全局安装等,但仍然无法识别)原来我没有为 npm 指定环境变量(文件 webpack.cmd 在哪里)所以我添加到我的路径变量
I had this issue for a long time too. (webpack installed globally etc. but still not recognized) It turned out that I haven't specified enviroment variable for npm (where is file webpack.cmd sitting) So I add to my Path variable
%USERPROFILE%\AppData\Roaming\npm\
如果您使用的是 Powershell,您可以输入以下命令来有效地添加到您的路径中:
If you are using Powershell, you can type the following command to effectively add to your path :
[Environment]::SetEnvironmentVariable("Path", "$env:Path;%USERPROFILE%\AppData\Roaming\npm\", "User")
重要提示:不要忘记关闭并重新打开您的 Powershell 窗口以应用此功能.
IMPORTANT : Don't forget to close and re-open your powershell window in order to apply this.
这篇关于webpack 不是内部或外部命令,也不是可运行的程序或批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!