6

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?

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This answer is unclear. Can you please post exact solution to the problem ? what steps did u take to solve it ?
For me this was solved by adding the following to the webpack config: context: __dirname Depending on your setup you might need something like context: path.join(__dirname, '../')

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.