vuejs2webpack-4

Webpack version 4 installation does not work


For my Vue project I need to use webpack, specifically version 4 in consideration with my other dependencies. However, whenever I try to npm install webpack@4 --save-dev it just enters a loop that never ends and seems buggy.

Does anyone know how to resolve this problem?

I tried Googling the issue and visited stackoverflow. But none of the other suggestions I found worked for me.


Solution

  • I suggest using the official Vue 2 scaffolding tool, vue/cli. If you already have it installed and it's version number is >= 5.x (check with command vue --version), it will install webpack 5, so first uninstall it with npm uninstall -g @vue/cli. Reinstall using a version number that will install webpack 4:

    npm install -g @vue/cli@4.5.19
    

    Then run the command to create a new Vue project, vue create my-project.

    This will scaffold a Vue project for you with webpack 4. You can confirm by checking "node_modules/webpack" in package.json.