'Issues with installing express.js on a nuxt/vue project

I'm struggling with installing and initiating express.js in a nuxt/vue project. This question correlates to my previous ones as the reason they didn't work is this. I might be asking a lot of questions but this project has suddenly turned into shambles. Whenever I install and include express.js in a project I get errors such as Module not found: Error: Can't resolve 'async_hooks' for packages which were installed with express.js (on_finished, raw_body). There's also another couple of errors which I'll have pasted down below. The project works perfectly without express, when using express my whole vue also doesn't work as demonstrated in my previous questions.

Errors: (npm run dev with middleware/express)

WARN  Compiled with 3 warnings                                                              

WARN  in C:/Users/Gibbo/node_modules/express/lib/view.js                                  
Critical dependency: the request of a dependency is an expression   
                         
WARN  in C:/Users/Gibbo/node_modules/on-finished/index.js                                    
Module not found: Error: Can't resolve 'async_hooks' in 'C:\Users\Gibbo\node_modules\on-finished'                                                                                             

WARN  in C:/Users/Gibbo/node_modules/raw-body/index.js                                       
Module not found: Error: Can't resolve 'async_hooks' in 'C:\Users\Gibbo\node_modules\raw-body'

ERROR  Failed to compile with 6 errors                                                       -

These dependencies were not found:                                                            
* fs in C:/Users/Gibbo/node_modules/destroy/index.js, C:/Users/Gibbo/node_modules/etag/index.js and 3 others
* net in C:/Users/Gibbo/node_modules/express/lib/request.js                                   
To install them, you can run: npm install --save fs net

You can likely reproduce this error by using npm init create-nuxt test and making an server file in a middleware folder. I made a github repo if anyone wants to reproduce it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source