vuejs webpack relative modules were not found error

14,502

This is the error with relative paths. You need to change all paths exept those with used in require(), relative to the new root folder, not the client folder. Good practice is using of __dirname which is same to path.diranme() method. Check this.

Share:
14,502
Admin
Author by

Admin

Updated on June 13, 2022

Comments

  • Admin
    Admin almost 2 years

    I have full-stack application with express and default vue-webpack-boilerplate. My project structure looks like this:

    ├── client
    │   ├── build
    │   │   └── ...
    │   ├── config
    │   │   └── ...
    │   ├── dist
    |   |   └── ...
    │   ├── index.html
    │   ├── src
    │   │   ├── App.vue
    │   │   ├── assets
    │   │   │   └── ...
    │   │   ├── components
    │   │   │   └── ...
    │   │   ├── main.js
    │   │   └── router
    │   └── static
    ├── node_modules
    ├── package.json
    └── server
        ├── app.js
        ├── bin
        │   └── www
        └── routes
            └── ...
    

    When I run $ node client/build/dev-server.js i receive this error:

    ERROR  Failed to compile with 2 errors
    
    These relative modules were not found:
    
    * ./build/dev-client in multi ./build/dev-client ./src/main.js
    * ./src/main.js in multi ./build/dev-client ./src/main.js
    

    but only if I trying to run it from client folder it works properly.

    $ cd client 
    $ node build/dev-server.js
    

    any suggestions?