webpack is not recognized as a internal or external command,operable program or batch file
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 is not recognized as a internal or external command,operable program or batch file
npm webpack
add a comment |
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 is not recognized as a internal or external command,operable program or batch file
npm webpack
add a comment |
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 is not recognized as a internal or external command,operable program or batch file
npm webpack
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 is not recognized as a internal or external command,operable program or batch file
npm webpack
npm webpack
asked Mar 5 '16 at 4:52
yasar yasar
6462717
6462717
add a comment |
add a comment |
13 Answers
13
active
oldest
votes
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%AppDataRoamingnpm
If you are using Powershell, you can type the following command to effectively add to your path :
[Environment]::SetEnvironmentVariable("Path", "$env:Path;%USERPROFILE%AppDataRoamingnpm", "User")
IMPORTANT : Don't forget to close and re-open your powershell window in order to apply this.
Hope it helps.
5
well Iam stuck at the same place...Can u please elaborate ur answer
– Intruder
Mar 25 '16 at 17:12
1
I was following all the steps but it did not work then finally I realized, I did not open CMD as administrator.
– Hosein Djadidi
May 5 '17 at 21:28
1
I did it already but still facing same issue
– VjyV
Apr 27 '18 at 10:08
Thank you! this worked :)
– Chris
Oct 17 '18 at 18:51
add a comment |
Better solution to this problem is to install Webpack
globally.
This always works and it worked for me. Try below command.
npm install -g webpack
26
I think it should be noted that using the -g installs webpack globally, which you may not want if you have multiple projects that may require different versions of webpack.
– Uber Schnoz
Mar 13 '17 at 17:59
add a comment |
As an alternative, if you have Webpack installed locally, you can explicitly specify where Command Prompt should look to find it, like so:
node_modules.binwebpack
(This does assume that you're inside the directory with your package.json
and that you've already run npm install webpack
.)
5
this should be the accepted answer
– Max Favilli
Dec 2 '17 at 15:38
4
Agree with Max, the reason being that it is recommended to have webpack installed locally (in devDependencies) - My problem was a little different though, when adding webpack as a pre build step in VS 2017, I thought VS was smart enough to find the webpack cmd locally without the full path
– JimiSweden
Dec 15 '17 at 9:23
@JimiSweden did you try addingnode_modules.bin
to tools->configure external tools
– Max Favilli
Jan 15 '18 at 19:21
1
You could try usingnpx webpack
which also checks./node_modules/.bin
instead of fiddling with paths.
– Manfred
Jan 18 at 20:06
add a comment |
npm install -g webpack-dev-server
will solve your issue
1
It may solve the error message OP posted, but this is not a good solution to the problem as it adds more dependencies than just solving the missing webpack. See any of the other high-voted answers for better alternatives.
– angularsen
Jan 4 at 11:59
As pointed out by different contributors already (see other answers/comments), installing globally is considered bad practice as it locks you down to one version. See also webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:07
add a comment |
Add webpack command as an npm script in your package.json.
{
"name": "react-app",
"version": "1.0.0",
"scripts": {
"compile": "webpack --config webpack.config.js"
}
}
Then run
npm run compile
When the webpack is installed it creates a binary in ./node_modules/.bin folder. npm scripts also looks for executable created in this folder
does not work - npm install -g webpack-dev-server is correct command
– TarmoPikaro
Aug 17 '18 at 5:58
add a comment |
Webpack CLI is now in a separate package and must be installed globally in order to use the 'webpack' command:
npm install -g webpack-cli
That worked for me :)
– Mik
Jun 8 '18 at 7:41
"must be installed globally" is not correct as I understand it. Even the webpack folks advise against it. See webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:09
add a comment |
Just run your command line (cmd) as an administrator.
add a comment |
I've had same issue and just added the code block into my package.json file;
"scripts": {
"build": "webpack -d --progress --colors"
}
and then run command on terminal;
npm run build
This worked for me. Thanks for sharing.
– Srihari Sridharan
Jan 10 '18 at 7:35
add a comment |
Try deleting node_modules in local directory and re-run npm install.
add a comment |
you have to install webpack and webpack-cli in the same scope.
npm i -g webpack webpack-cli
or,
npm i webpack webpack-cli
if you install it locally you need to call it specifially
node_modules/.bin/webpack -v
Or, if installed locally, you could usenpx webpack
(tested with npm version 6.5.0, webpack 4.28.4 and webpack-cli 3.2.1)
– Manfred
Jan 18 at 20:10
add a comment |
I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.
add a comment |
We also experienced this problem and I like all the answers that suggest using a script defined in package.json
.
For our solutions we often use the following sequence:
npm install --save-dev webpack-cli
(if you're using webpack v4 or later, otherwise usenpm install --save-dev webpack
, see webpack installation, retrieved 19 Jan 2019)npx webpack
Step 1 is a one-off. Step 2 also checks ./node_modules/.bin
. You can add the second step as a npm script to package.json
as well, for example:
{
...
"scripts": {
...
"build": "npx webpack --mode development",
...
},
...
}
and then use npm run build
to execute this script.
Tested this solution with npm version 6.5.0, webpack version 4.28.4 and webpack-cli version 3.2.1 on Windows 10, executing all commands inside of a PowerShell window. My nodejs version is/was 10.14.2. I also tested this on Ubuntu Linux version 18.04.
I'd advise against installing webpack globally, in particular if you are working with a lot of different projects each of which may require a different version of webpack. Installing webpack globally locks you down to a particular version across all projects on the same machine.
add a comment |
Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.
1
-g installs globally (not your local project node_modules + package.json) while --save installs locally (in your local node_modules + package.json) so this answer is wrong.
– George
Feb 9 '18 at 15:58
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35810172%2fwebpack-is-not-recognized-as-a-internal-or-external-command-operable-program-or%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
13 Answers
13
active
oldest
votes
13 Answers
13
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%AppDataRoamingnpm
If you are using Powershell, you can type the following command to effectively add to your path :
[Environment]::SetEnvironmentVariable("Path", "$env:Path;%USERPROFILE%AppDataRoamingnpm", "User")
IMPORTANT : Don't forget to close and re-open your powershell window in order to apply this.
Hope it helps.
5
well Iam stuck at the same place...Can u please elaborate ur answer
– Intruder
Mar 25 '16 at 17:12
1
I was following all the steps but it did not work then finally I realized, I did not open CMD as administrator.
– Hosein Djadidi
May 5 '17 at 21:28
1
I did it already but still facing same issue
– VjyV
Apr 27 '18 at 10:08
Thank you! this worked :)
– Chris
Oct 17 '18 at 18:51
add a comment |
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%AppDataRoamingnpm
If you are using Powershell, you can type the following command to effectively add to your path :
[Environment]::SetEnvironmentVariable("Path", "$env:Path;%USERPROFILE%AppDataRoamingnpm", "User")
IMPORTANT : Don't forget to close and re-open your powershell window in order to apply this.
Hope it helps.
5
well Iam stuck at the same place...Can u please elaborate ur answer
– Intruder
Mar 25 '16 at 17:12
1
I was following all the steps but it did not work then finally I realized, I did not open CMD as administrator.
– Hosein Djadidi
May 5 '17 at 21:28
1
I did it already but still facing same issue
– VjyV
Apr 27 '18 at 10:08
Thank you! this worked :)
– Chris
Oct 17 '18 at 18:51
add a comment |
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%AppDataRoamingnpm
If you are using Powershell, you can type the following command to effectively add to your path :
[Environment]::SetEnvironmentVariable("Path", "$env:Path;%USERPROFILE%AppDataRoamingnpm", "User")
IMPORTANT : Don't forget to close and re-open your powershell window in order to apply this.
Hope it helps.
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%AppDataRoamingnpm
If you are using Powershell, you can type the following command to effectively add to your path :
[Environment]::SetEnvironmentVariable("Path", "$env:Path;%USERPROFILE%AppDataRoamingnpm", "User")
IMPORTANT : Don't forget to close and re-open your powershell window in order to apply this.
Hope it helps.
edited Aug 6 '18 at 18:20
jklemmack
2,51512238
2,51512238
answered Mar 5 '16 at 18:24
VladoVlado
65467
65467
5
well Iam stuck at the same place...Can u please elaborate ur answer
– Intruder
Mar 25 '16 at 17:12
1
I was following all the steps but it did not work then finally I realized, I did not open CMD as administrator.
– Hosein Djadidi
May 5 '17 at 21:28
1
I did it already but still facing same issue
– VjyV
Apr 27 '18 at 10:08
Thank you! this worked :)
– Chris
Oct 17 '18 at 18:51
add a comment |
5
well Iam stuck at the same place...Can u please elaborate ur answer
– Intruder
Mar 25 '16 at 17:12
1
I was following all the steps but it did not work then finally I realized, I did not open CMD as administrator.
– Hosein Djadidi
May 5 '17 at 21:28
1
I did it already but still facing same issue
– VjyV
Apr 27 '18 at 10:08
Thank you! this worked :)
– Chris
Oct 17 '18 at 18:51
5
5
well Iam stuck at the same place...Can u please elaborate ur answer
– Intruder
Mar 25 '16 at 17:12
well Iam stuck at the same place...Can u please elaborate ur answer
– Intruder
Mar 25 '16 at 17:12
1
1
I was following all the steps but it did not work then finally I realized, I did not open CMD as administrator.
– Hosein Djadidi
May 5 '17 at 21:28
I was following all the steps but it did not work then finally I realized, I did not open CMD as administrator.
– Hosein Djadidi
May 5 '17 at 21:28
1
1
I did it already but still facing same issue
– VjyV
Apr 27 '18 at 10:08
I did it already but still facing same issue
– VjyV
Apr 27 '18 at 10:08
Thank you! this worked :)
– Chris
Oct 17 '18 at 18:51
Thank you! this worked :)
– Chris
Oct 17 '18 at 18:51
add a comment |
Better solution to this problem is to install Webpack
globally.
This always works and it worked for me. Try below command.
npm install -g webpack
26
I think it should be noted that using the -g installs webpack globally, which you may not want if you have multiple projects that may require different versions of webpack.
– Uber Schnoz
Mar 13 '17 at 17:59
add a comment |
Better solution to this problem is to install Webpack
globally.
This always works and it worked for me. Try below command.
npm install -g webpack
26
I think it should be noted that using the -g installs webpack globally, which you may not want if you have multiple projects that may require different versions of webpack.
– Uber Schnoz
Mar 13 '17 at 17:59
add a comment |
Better solution to this problem is to install Webpack
globally.
This always works and it worked for me. Try below command.
npm install -g webpack
Better solution to this problem is to install Webpack
globally.
This always works and it worked for me. Try below command.
npm install -g webpack
edited Oct 21 '16 at 9:49
DrDom
2,7741622
2,7741622
answered Oct 21 '16 at 9:13
srikanth_ksrikanth_k
1,4962814
1,4962814
26
I think it should be noted that using the -g installs webpack globally, which you may not want if you have multiple projects that may require different versions of webpack.
– Uber Schnoz
Mar 13 '17 at 17:59
add a comment |
26
I think it should be noted that using the -g installs webpack globally, which you may not want if you have multiple projects that may require different versions of webpack.
– Uber Schnoz
Mar 13 '17 at 17:59
26
26
I think it should be noted that using the -g installs webpack globally, which you may not want if you have multiple projects that may require different versions of webpack.
– Uber Schnoz
Mar 13 '17 at 17:59
I think it should be noted that using the -g installs webpack globally, which you may not want if you have multiple projects that may require different versions of webpack.
– Uber Schnoz
Mar 13 '17 at 17:59
add a comment |
As an alternative, if you have Webpack installed locally, you can explicitly specify where Command Prompt should look to find it, like so:
node_modules.binwebpack
(This does assume that you're inside the directory with your package.json
and that you've already run npm install webpack
.)
5
this should be the accepted answer
– Max Favilli
Dec 2 '17 at 15:38
4
Agree with Max, the reason being that it is recommended to have webpack installed locally (in devDependencies) - My problem was a little different though, when adding webpack as a pre build step in VS 2017, I thought VS was smart enough to find the webpack cmd locally without the full path
– JimiSweden
Dec 15 '17 at 9:23
@JimiSweden did you try addingnode_modules.bin
to tools->configure external tools
– Max Favilli
Jan 15 '18 at 19:21
1
You could try usingnpx webpack
which also checks./node_modules/.bin
instead of fiddling with paths.
– Manfred
Jan 18 at 20:06
add a comment |
As an alternative, if you have Webpack installed locally, you can explicitly specify where Command Prompt should look to find it, like so:
node_modules.binwebpack
(This does assume that you're inside the directory with your package.json
and that you've already run npm install webpack
.)
5
this should be the accepted answer
– Max Favilli
Dec 2 '17 at 15:38
4
Agree with Max, the reason being that it is recommended to have webpack installed locally (in devDependencies) - My problem was a little different though, when adding webpack as a pre build step in VS 2017, I thought VS was smart enough to find the webpack cmd locally without the full path
– JimiSweden
Dec 15 '17 at 9:23
@JimiSweden did you try addingnode_modules.bin
to tools->configure external tools
– Max Favilli
Jan 15 '18 at 19:21
1
You could try usingnpx webpack
which also checks./node_modules/.bin
instead of fiddling with paths.
– Manfred
Jan 18 at 20:06
add a comment |
As an alternative, if you have Webpack installed locally, you can explicitly specify where Command Prompt should look to find it, like so:
node_modules.binwebpack
(This does assume that you're inside the directory with your package.json
and that you've already run npm install webpack
.)
As an alternative, if you have Webpack installed locally, you can explicitly specify where Command Prompt should look to find it, like so:
node_modules.binwebpack
(This does assume that you're inside the directory with your package.json
and that you've already run npm install webpack
.)
edited Jan 2 at 12:12
answered Jul 27 '16 at 20:09
BalinKingOfMoriaBalinKingOfMoria
1,2201025
1,2201025
5
this should be the accepted answer
– Max Favilli
Dec 2 '17 at 15:38
4
Agree with Max, the reason being that it is recommended to have webpack installed locally (in devDependencies) - My problem was a little different though, when adding webpack as a pre build step in VS 2017, I thought VS was smart enough to find the webpack cmd locally without the full path
– JimiSweden
Dec 15 '17 at 9:23
@JimiSweden did you try addingnode_modules.bin
to tools->configure external tools
– Max Favilli
Jan 15 '18 at 19:21
1
You could try usingnpx webpack
which also checks./node_modules/.bin
instead of fiddling with paths.
– Manfred
Jan 18 at 20:06
add a comment |
5
this should be the accepted answer
– Max Favilli
Dec 2 '17 at 15:38
4
Agree with Max, the reason being that it is recommended to have webpack installed locally (in devDependencies) - My problem was a little different though, when adding webpack as a pre build step in VS 2017, I thought VS was smart enough to find the webpack cmd locally without the full path
– JimiSweden
Dec 15 '17 at 9:23
@JimiSweden did you try addingnode_modules.bin
to tools->configure external tools
– Max Favilli
Jan 15 '18 at 19:21
1
You could try usingnpx webpack
which also checks./node_modules/.bin
instead of fiddling with paths.
– Manfred
Jan 18 at 20:06
5
5
this should be the accepted answer
– Max Favilli
Dec 2 '17 at 15:38
this should be the accepted answer
– Max Favilli
Dec 2 '17 at 15:38
4
4
Agree with Max, the reason being that it is recommended to have webpack installed locally (in devDependencies) - My problem was a little different though, when adding webpack as a pre build step in VS 2017, I thought VS was smart enough to find the webpack cmd locally without the full path
– JimiSweden
Dec 15 '17 at 9:23
Agree with Max, the reason being that it is recommended to have webpack installed locally (in devDependencies) - My problem was a little different though, when adding webpack as a pre build step in VS 2017, I thought VS was smart enough to find the webpack cmd locally without the full path
– JimiSweden
Dec 15 '17 at 9:23
@JimiSweden did you try adding
node_modules.bin
to tools->configure external tools– Max Favilli
Jan 15 '18 at 19:21
@JimiSweden did you try adding
node_modules.bin
to tools->configure external tools– Max Favilli
Jan 15 '18 at 19:21
1
1
You could try using
npx webpack
which also checks ./node_modules/.bin
instead of fiddling with paths.– Manfred
Jan 18 at 20:06
You could try using
npx webpack
which also checks ./node_modules/.bin
instead of fiddling with paths.– Manfred
Jan 18 at 20:06
add a comment |
npm install -g webpack-dev-server
will solve your issue
1
It may solve the error message OP posted, but this is not a good solution to the problem as it adds more dependencies than just solving the missing webpack. See any of the other high-voted answers for better alternatives.
– angularsen
Jan 4 at 11:59
As pointed out by different contributors already (see other answers/comments), installing globally is considered bad practice as it locks you down to one version. See also webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:07
add a comment |
npm install -g webpack-dev-server
will solve your issue
1
It may solve the error message OP posted, but this is not a good solution to the problem as it adds more dependencies than just solving the missing webpack. See any of the other high-voted answers for better alternatives.
– angularsen
Jan 4 at 11:59
As pointed out by different contributors already (see other answers/comments), installing globally is considered bad practice as it locks you down to one version. See also webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:07
add a comment |
npm install -g webpack-dev-server
will solve your issue
npm install -g webpack-dev-server
will solve your issue
edited Aug 7 '16 at 10:12
Nikolay Kostov
8,8441862107
8,8441862107
answered Aug 7 '16 at 9:49
Araali FarooqAraali Farooq
39534
39534
1
It may solve the error message OP posted, but this is not a good solution to the problem as it adds more dependencies than just solving the missing webpack. See any of the other high-voted answers for better alternatives.
– angularsen
Jan 4 at 11:59
As pointed out by different contributors already (see other answers/comments), installing globally is considered bad practice as it locks you down to one version. See also webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:07
add a comment |
1
It may solve the error message OP posted, but this is not a good solution to the problem as it adds more dependencies than just solving the missing webpack. See any of the other high-voted answers for better alternatives.
– angularsen
Jan 4 at 11:59
As pointed out by different contributors already (see other answers/comments), installing globally is considered bad practice as it locks you down to one version. See also webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:07
1
1
It may solve the error message OP posted, but this is not a good solution to the problem as it adds more dependencies than just solving the missing webpack. See any of the other high-voted answers for better alternatives.
– angularsen
Jan 4 at 11:59
It may solve the error message OP posted, but this is not a good solution to the problem as it adds more dependencies than just solving the missing webpack. See any of the other high-voted answers for better alternatives.
– angularsen
Jan 4 at 11:59
As pointed out by different contributors already (see other answers/comments), installing globally is considered bad practice as it locks you down to one version. See also webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:07
As pointed out by different contributors already (see other answers/comments), installing globally is considered bad practice as it locks you down to one version. See also webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:07
add a comment |
Add webpack command as an npm script in your package.json.
{
"name": "react-app",
"version": "1.0.0",
"scripts": {
"compile": "webpack --config webpack.config.js"
}
}
Then run
npm run compile
When the webpack is installed it creates a binary in ./node_modules/.bin folder. npm scripts also looks for executable created in this folder
does not work - npm install -g webpack-dev-server is correct command
– TarmoPikaro
Aug 17 '18 at 5:58
add a comment |
Add webpack command as an npm script in your package.json.
{
"name": "react-app",
"version": "1.0.0",
"scripts": {
"compile": "webpack --config webpack.config.js"
}
}
Then run
npm run compile
When the webpack is installed it creates a binary in ./node_modules/.bin folder. npm scripts also looks for executable created in this folder
does not work - npm install -g webpack-dev-server is correct command
– TarmoPikaro
Aug 17 '18 at 5:58
add a comment |
Add webpack command as an npm script in your package.json.
{
"name": "react-app",
"version": "1.0.0",
"scripts": {
"compile": "webpack --config webpack.config.js"
}
}
Then run
npm run compile
When the webpack is installed it creates a binary in ./node_modules/.bin folder. npm scripts also looks for executable created in this folder
Add webpack command as an npm script in your package.json.
{
"name": "react-app",
"version": "1.0.0",
"scripts": {
"compile": "webpack --config webpack.config.js"
}
}
Then run
npm run compile
When the webpack is installed it creates a binary in ./node_modules/.bin folder. npm scripts also looks for executable created in this folder
answered May 27 '17 at 20:41
Nikhil RanjanNikhil Ranjan
750813
750813
does not work - npm install -g webpack-dev-server is correct command
– TarmoPikaro
Aug 17 '18 at 5:58
add a comment |
does not work - npm install -g webpack-dev-server is correct command
– TarmoPikaro
Aug 17 '18 at 5:58
does not work - npm install -g webpack-dev-server is correct command
– TarmoPikaro
Aug 17 '18 at 5:58
does not work - npm install -g webpack-dev-server is correct command
– TarmoPikaro
Aug 17 '18 at 5:58
add a comment |
Webpack CLI is now in a separate package and must be installed globally in order to use the 'webpack' command:
npm install -g webpack-cli
That worked for me :)
– Mik
Jun 8 '18 at 7:41
"must be installed globally" is not correct as I understand it. Even the webpack folks advise against it. See webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:09
add a comment |
Webpack CLI is now in a separate package and must be installed globally in order to use the 'webpack' command:
npm install -g webpack-cli
That worked for me :)
– Mik
Jun 8 '18 at 7:41
"must be installed globally" is not correct as I understand it. Even the webpack folks advise against it. See webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:09
add a comment |
Webpack CLI is now in a separate package and must be installed globally in order to use the 'webpack' command:
npm install -g webpack-cli
Webpack CLI is now in a separate package and must be installed globally in order to use the 'webpack' command:
npm install -g webpack-cli
answered Apr 23 '18 at 14:02
averroesaverroes
450619
450619
That worked for me :)
– Mik
Jun 8 '18 at 7:41
"must be installed globally" is not correct as I understand it. Even the webpack folks advise against it. See webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:09
add a comment |
That worked for me :)
– Mik
Jun 8 '18 at 7:41
"must be installed globally" is not correct as I understand it. Even the webpack folks advise against it. See webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:09
That worked for me :)
– Mik
Jun 8 '18 at 7:41
That worked for me :)
– Mik
Jun 8 '18 at 7:41
"must be installed globally" is not correct as I understand it. Even the webpack folks advise against it. See webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:09
"must be installed globally" is not correct as I understand it. Even the webpack folks advise against it. See webpack.js.org/guides/installation
– Manfred
Jan 18 at 20:09
add a comment |
Just run your command line (cmd) as an administrator.
add a comment |
Just run your command line (cmd) as an administrator.
add a comment |
Just run your command line (cmd) as an administrator.
Just run your command line (cmd) as an administrator.
answered Oct 31 '16 at 19:16
ZOALITZOALIT
472
472
add a comment |
add a comment |
I've had same issue and just added the code block into my package.json file;
"scripts": {
"build": "webpack -d --progress --colors"
}
and then run command on terminal;
npm run build
This worked for me. Thanks for sharing.
– Srihari Sridharan
Jan 10 '18 at 7:35
add a comment |
I've had same issue and just added the code block into my package.json file;
"scripts": {
"build": "webpack -d --progress --colors"
}
and then run command on terminal;
npm run build
This worked for me. Thanks for sharing.
– Srihari Sridharan
Jan 10 '18 at 7:35
add a comment |
I've had same issue and just added the code block into my package.json file;
"scripts": {
"build": "webpack -d --progress --colors"
}
and then run command on terminal;
npm run build
I've had same issue and just added the code block into my package.json file;
"scripts": {
"build": "webpack -d --progress --colors"
}
and then run command on terminal;
npm run build
answered Jun 5 '17 at 13:42
B.BraveB.Brave
303
303
This worked for me. Thanks for sharing.
– Srihari Sridharan
Jan 10 '18 at 7:35
add a comment |
This worked for me. Thanks for sharing.
– Srihari Sridharan
Jan 10 '18 at 7:35
This worked for me. Thanks for sharing.
– Srihari Sridharan
Jan 10 '18 at 7:35
This worked for me. Thanks for sharing.
– Srihari Sridharan
Jan 10 '18 at 7:35
add a comment |
Try deleting node_modules in local directory and re-run npm install.
add a comment |
Try deleting node_modules in local directory and re-run npm install.
add a comment |
Try deleting node_modules in local directory and re-run npm install.
Try deleting node_modules in local directory and re-run npm install.
answered May 26 '18 at 12:00
Dushyant SinghDushyant Singh
554
554
add a comment |
add a comment |
you have to install webpack and webpack-cli in the same scope.
npm i -g webpack webpack-cli
or,
npm i webpack webpack-cli
if you install it locally you need to call it specifially
node_modules/.bin/webpack -v
Or, if installed locally, you could usenpx webpack
(tested with npm version 6.5.0, webpack 4.28.4 and webpack-cli 3.2.1)
– Manfred
Jan 18 at 20:10
add a comment |
you have to install webpack and webpack-cli in the same scope.
npm i -g webpack webpack-cli
or,
npm i webpack webpack-cli
if you install it locally you need to call it specifially
node_modules/.bin/webpack -v
Or, if installed locally, you could usenpx webpack
(tested with npm version 6.5.0, webpack 4.28.4 and webpack-cli 3.2.1)
– Manfred
Jan 18 at 20:10
add a comment |
you have to install webpack and webpack-cli in the same scope.
npm i -g webpack webpack-cli
or,
npm i webpack webpack-cli
if you install it locally you need to call it specifially
node_modules/.bin/webpack -v
you have to install webpack and webpack-cli in the same scope.
npm i -g webpack webpack-cli
or,
npm i webpack webpack-cli
if you install it locally you need to call it specifially
node_modules/.bin/webpack -v
answered Sep 23 '18 at 9:21
Irteza AsadIrteza Asad
16123
16123
Or, if installed locally, you could usenpx webpack
(tested with npm version 6.5.0, webpack 4.28.4 and webpack-cli 3.2.1)
– Manfred
Jan 18 at 20:10
add a comment |
Or, if installed locally, you could usenpx webpack
(tested with npm version 6.5.0, webpack 4.28.4 and webpack-cli 3.2.1)
– Manfred
Jan 18 at 20:10
Or, if installed locally, you could use
npx webpack
(tested with npm version 6.5.0, webpack 4.28.4 and webpack-cli 3.2.1)– Manfred
Jan 18 at 20:10
Or, if installed locally, you could use
npx webpack
(tested with npm version 6.5.0, webpack 4.28.4 and webpack-cli 3.2.1)– Manfred
Jan 18 at 20:10
add a comment |
I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.
add a comment |
I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.
add a comment |
I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.
I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.
answered Jul 19 '18 at 4:56
Simon XiaoSimon Xiao
1
1
add a comment |
add a comment |
We also experienced this problem and I like all the answers that suggest using a script defined in package.json
.
For our solutions we often use the following sequence:
npm install --save-dev webpack-cli
(if you're using webpack v4 or later, otherwise usenpm install --save-dev webpack
, see webpack installation, retrieved 19 Jan 2019)npx webpack
Step 1 is a one-off. Step 2 also checks ./node_modules/.bin
. You can add the second step as a npm script to package.json
as well, for example:
{
...
"scripts": {
...
"build": "npx webpack --mode development",
...
},
...
}
and then use npm run build
to execute this script.
Tested this solution with npm version 6.5.0, webpack version 4.28.4 and webpack-cli version 3.2.1 on Windows 10, executing all commands inside of a PowerShell window. My nodejs version is/was 10.14.2. I also tested this on Ubuntu Linux version 18.04.
I'd advise against installing webpack globally, in particular if you are working with a lot of different projects each of which may require a different version of webpack. Installing webpack globally locks you down to a particular version across all projects on the same machine.
add a comment |
We also experienced this problem and I like all the answers that suggest using a script defined in package.json
.
For our solutions we often use the following sequence:
npm install --save-dev webpack-cli
(if you're using webpack v4 or later, otherwise usenpm install --save-dev webpack
, see webpack installation, retrieved 19 Jan 2019)npx webpack
Step 1 is a one-off. Step 2 also checks ./node_modules/.bin
. You can add the second step as a npm script to package.json
as well, for example:
{
...
"scripts": {
...
"build": "npx webpack --mode development",
...
},
...
}
and then use npm run build
to execute this script.
Tested this solution with npm version 6.5.0, webpack version 4.28.4 and webpack-cli version 3.2.1 on Windows 10, executing all commands inside of a PowerShell window. My nodejs version is/was 10.14.2. I also tested this on Ubuntu Linux version 18.04.
I'd advise against installing webpack globally, in particular if you are working with a lot of different projects each of which may require a different version of webpack. Installing webpack globally locks you down to a particular version across all projects on the same machine.
add a comment |
We also experienced this problem and I like all the answers that suggest using a script defined in package.json
.
For our solutions we often use the following sequence:
npm install --save-dev webpack-cli
(if you're using webpack v4 or later, otherwise usenpm install --save-dev webpack
, see webpack installation, retrieved 19 Jan 2019)npx webpack
Step 1 is a one-off. Step 2 also checks ./node_modules/.bin
. You can add the second step as a npm script to package.json
as well, for example:
{
...
"scripts": {
...
"build": "npx webpack --mode development",
...
},
...
}
and then use npm run build
to execute this script.
Tested this solution with npm version 6.5.0, webpack version 4.28.4 and webpack-cli version 3.2.1 on Windows 10, executing all commands inside of a PowerShell window. My nodejs version is/was 10.14.2. I also tested this on Ubuntu Linux version 18.04.
I'd advise against installing webpack globally, in particular if you are working with a lot of different projects each of which may require a different version of webpack. Installing webpack globally locks you down to a particular version across all projects on the same machine.
We also experienced this problem and I like all the answers that suggest using a script defined in package.json
.
For our solutions we often use the following sequence:
npm install --save-dev webpack-cli
(if you're using webpack v4 or later, otherwise usenpm install --save-dev webpack
, see webpack installation, retrieved 19 Jan 2019)npx webpack
Step 1 is a one-off. Step 2 also checks ./node_modules/.bin
. You can add the second step as a npm script to package.json
as well, for example:
{
...
"scripts": {
...
"build": "npx webpack --mode development",
...
},
...
}
and then use npm run build
to execute this script.
Tested this solution with npm version 6.5.0, webpack version 4.28.4 and webpack-cli version 3.2.1 on Windows 10, executing all commands inside of a PowerShell window. My nodejs version is/was 10.14.2. I also tested this on Ubuntu Linux version 18.04.
I'd advise against installing webpack globally, in particular if you are working with a lot of different projects each of which may require a different version of webpack. Installing webpack globally locks you down to a particular version across all projects on the same machine.
edited Jan 18 at 20:12
answered Jan 18 at 20:01
ManfredManfred
3,91611924
3,91611924
add a comment |
add a comment |
Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.
1
-g installs globally (not your local project node_modules + package.json) while --save installs locally (in your local node_modules + package.json) so this answer is wrong.
– George
Feb 9 '18 at 15:58
add a comment |
Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.
1
-g installs globally (not your local project node_modules + package.json) while --save installs locally (in your local node_modules + package.json) so this answer is wrong.
– George
Feb 9 '18 at 15:58
add a comment |
Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.
Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.
answered Dec 14 '17 at 7:03
Amartya BanerjeeAmartya Banerjee
1
1
1
-g installs globally (not your local project node_modules + package.json) while --save installs locally (in your local node_modules + package.json) so this answer is wrong.
– George
Feb 9 '18 at 15:58
add a comment |
1
-g installs globally (not your local project node_modules + package.json) while --save installs locally (in your local node_modules + package.json) so this answer is wrong.
– George
Feb 9 '18 at 15:58
1
1
-g installs globally (not your local project node_modules + package.json) while --save installs locally (in your local node_modules + package.json) so this answer is wrong.
– George
Feb 9 '18 at 15:58
-g installs globally (not your local project node_modules + package.json) while --save installs locally (in your local node_modules + package.json) so this answer is wrong.
– George
Feb 9 '18 at 15:58
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35810172%2fwebpack-is-not-recognized-as-a-internal-or-external-command-operable-program-or%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown