webpack is not recognized as a internal or external command,operable program or batch file












80















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










share|improve this question



























    80















    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










    share|improve this question

























      80












      80








      80


      12






      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










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 5 '16 at 4:52









      yasar yasar

      6462717




      6462717
























          13 Answers
          13






          active

          oldest

          votes


















          60














          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.






          share|improve this answer





















          • 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



















          121














          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





          share|improve this answer





















          • 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



















          66














          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.)






          share|improve this answer





















          • 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 adding node_modules.bin to tools->configure external tools

            – Max Favilli
            Jan 15 '18 at 19:21






          • 1





            You could try using npx webpack which also checks ./node_modules/.bin instead of fiddling with paths.

            – Manfred
            Jan 18 at 20:06



















          37














          npm install -g webpack-dev-server will solve your issue






          share|improve this answer





















          • 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



















          9














          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






          share|improve this answer
























          • does not work - npm install -g webpack-dev-server is correct command

            – TarmoPikaro
            Aug 17 '18 at 5:58



















          7














          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





          share|improve this answer
























          • 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



















          3














          Just run your command line (cmd) as an administrator.






          share|improve this answer































            3














            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





            share|improve this answer
























            • This worked for me. Thanks for sharing.

              – Srihari Sridharan
              Jan 10 '18 at 7:35



















            3














            Try deleting node_modules in local directory and re-run npm install.






            share|improve this answer































              2














              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





              share|improve this answer
























              • 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



















              0














              I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.






              share|improve this answer































                0














                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:





                1. npm install --save-dev webpack-cli (if you're using webpack v4 or later, otherwise use npm install --save-dev webpack, see webpack installation, retrieved 19 Jan 2019)

                2. 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.






                share|improve this answer

































                  -1














                  Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.






                  share|improve this answer



















                  • 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











                  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
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  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









                  60














                  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.






                  share|improve this answer





















                  • 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
















                  60














                  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.






                  share|improve this answer





















                  • 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














                  60












                  60








                  60







                  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.






                  share|improve this answer















                  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.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  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














                  • 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













                  121














                  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





                  share|improve this answer





















                  • 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
















                  121














                  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





                  share|improve this answer





















                  • 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














                  121












                  121








                  121







                  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





                  share|improve this answer















                  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






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  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














                  • 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











                  66














                  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.)






                  share|improve this answer





















                  • 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 adding node_modules.bin to tools->configure external tools

                    – Max Favilli
                    Jan 15 '18 at 19:21






                  • 1





                    You could try using npx webpack which also checks ./node_modules/.bin instead of fiddling with paths.

                    – Manfred
                    Jan 18 at 20:06
















                  66














                  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.)






                  share|improve this answer





















                  • 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 adding node_modules.bin to tools->configure external tools

                    – Max Favilli
                    Jan 15 '18 at 19:21






                  • 1





                    You could try using npx webpack which also checks ./node_modules/.bin instead of fiddling with paths.

                    – Manfred
                    Jan 18 at 20:06














                  66












                  66








                  66







                  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.)






                  share|improve this answer















                  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.)







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  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 adding node_modules.bin to tools->configure external tools

                    – Max Favilli
                    Jan 15 '18 at 19:21






                  • 1





                    You could try using npx webpack which also checks ./node_modules/.bin instead of fiddling with paths.

                    – Manfred
                    Jan 18 at 20:06














                  • 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 adding node_modules.bin to tools->configure external tools

                    – Max Favilli
                    Jan 15 '18 at 19:21






                  • 1





                    You could try using npx 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











                  37














                  npm install -g webpack-dev-server will solve your issue






                  share|improve this answer





















                  • 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
















                  37














                  npm install -g webpack-dev-server will solve your issue






                  share|improve this answer





















                  • 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














                  37












                  37








                  37







                  npm install -g webpack-dev-server will solve your issue






                  share|improve this answer















                  npm install -g webpack-dev-server will solve your issue







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  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














                  • 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











                  9














                  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






                  share|improve this answer
























                  • does not work - npm install -g webpack-dev-server is correct command

                    – TarmoPikaro
                    Aug 17 '18 at 5:58
















                  9














                  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






                  share|improve this answer
























                  • does not work - npm install -g webpack-dev-server is correct command

                    – TarmoPikaro
                    Aug 17 '18 at 5:58














                  9












                  9








                  9







                  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






                  share|improve this answer













                  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







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  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



















                  • 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











                  7














                  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





                  share|improve this answer
























                  • 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
















                  7














                  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





                  share|improve this answer
























                  • 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














                  7












                  7








                  7







                  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





                  share|improve this answer













                  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






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  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



















                  • 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











                  3














                  Just run your command line (cmd) as an administrator.






                  share|improve this answer




























                    3














                    Just run your command line (cmd) as an administrator.






                    share|improve this answer


























                      3












                      3








                      3







                      Just run your command line (cmd) as an administrator.






                      share|improve this answer













                      Just run your command line (cmd) as an administrator.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Oct 31 '16 at 19:16









                      ZOALITZOALIT

                      472




                      472























                          3














                          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





                          share|improve this answer
























                          • This worked for me. Thanks for sharing.

                            – Srihari Sridharan
                            Jan 10 '18 at 7:35
















                          3














                          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





                          share|improve this answer
























                          • This worked for me. Thanks for sharing.

                            – Srihari Sridharan
                            Jan 10 '18 at 7:35














                          3












                          3








                          3







                          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





                          share|improve this answer













                          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






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          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



















                          • 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











                          3














                          Try deleting node_modules in local directory and re-run npm install.






                          share|improve this answer




























                            3














                            Try deleting node_modules in local directory and re-run npm install.






                            share|improve this answer


























                              3












                              3








                              3







                              Try deleting node_modules in local directory and re-run npm install.






                              share|improve this answer













                              Try deleting node_modules in local directory and re-run npm install.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered May 26 '18 at 12:00









                              Dushyant SinghDushyant Singh

                              554




                              554























                                  2














                                  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





                                  share|improve this answer
























                                  • 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
















                                  2














                                  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





                                  share|improve this answer
























                                  • 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














                                  2












                                  2








                                  2







                                  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





                                  share|improve this answer













                                  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






                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Sep 23 '18 at 9:21









                                  Irteza AsadIrteza Asad

                                  16123




                                  16123













                                  • 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

















                                  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











                                  0














                                  I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.






                                  share|improve this answer




























                                    0














                                    I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.






                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.






                                      share|improve this answer













                                      I got the same error, none of the solutions worked for me, I reinstalled node and that repaired my environment, everything works again.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jul 19 '18 at 4:56









                                      Simon XiaoSimon Xiao

                                      1




                                      1























                                          0














                                          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:





                                          1. npm install --save-dev webpack-cli (if you're using webpack v4 or later, otherwise use npm install --save-dev webpack, see webpack installation, retrieved 19 Jan 2019)

                                          2. 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.






                                          share|improve this answer






























                                            0














                                            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:





                                            1. npm install --save-dev webpack-cli (if you're using webpack v4 or later, otherwise use npm install --save-dev webpack, see webpack installation, retrieved 19 Jan 2019)

                                            2. 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.






                                            share|improve this answer




























                                              0












                                              0








                                              0







                                              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:





                                              1. npm install --save-dev webpack-cli (if you're using webpack v4 or later, otherwise use npm install --save-dev webpack, see webpack installation, retrieved 19 Jan 2019)

                                              2. 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.






                                              share|improve this answer















                                              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:





                                              1. npm install --save-dev webpack-cli (if you're using webpack v4 or later, otherwise use npm install --save-dev webpack, see webpack installation, retrieved 19 Jan 2019)

                                              2. 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.







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Jan 18 at 20:12

























                                              answered Jan 18 at 20:01









                                              ManfredManfred

                                              3,91611924




                                              3,91611924























                                                  -1














                                                  Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.






                                                  share|improve this answer



















                                                  • 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














                                                  Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.






                                                  share|improve this answer



















                                                  • 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








                                                  -1







                                                  Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.






                                                  share|improve this answer













                                                  Sometimes npm install -g webpack does not save properly. Better to use npm install webpack --save . It worked for me.







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  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














                                                  • 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


















                                                  draft saved

                                                  draft discarded




















































                                                  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.




                                                  draft saved


                                                  draft discarded














                                                  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





















































                                                  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







                                                  Popular posts from this blog

                                                  Homophylophilia

                                                  Updating UILabel text programmatically using a function

                                                  Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage