Vuejs webpack relative modules not found

I have a full stack app with express and standard vue-webpack template. 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 get 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 try to run it from the client folder it works correctly.

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

      

any suggestions?

+3


source to share


2 answers


This is a bug with relative paths. You need to change all paths other than those used in require()

to the new root folder, not the client folder. It is good practice to use __dirname

that is similar to the method path.diranme()

. Check this one out .



-1


source


I solved it by updating all npm packages: npm i -g npm-check-updates npm-check-updates -u npm install



make yours package.json

before performing the operation

-1


source







All Articles