Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vuejs webpack relative modules were not found error

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?

like image 846
Leomund Avatar asked Jul 12 '17 14:07

Leomund


1 Answers

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.

like image 131
Leomund Avatar answered Nov 12 '22 02:11

Leomund