'./node_modules/@prisma/client/runtime/index.js:35865:17-40 - Error: Module not found: Error: Can't resolve '_http_common'
I'm using angular universal with express-engine, the build for server fails with this error message:
./node_modules/@prisma/client/runtime/index.js:35865:17-40 - Error: Module not found: Error: Can't resolve '_http_common' in 'C:\Users\jude\Documents\Portfolio\evaluation-system\evaluation-system-app\node_modules@prisma\client\runtime'
Solution 1:[1]
After some google research, i figured out how to fix this bug:
install custom-webpack ( npm install @angular-builders/custom-webpack --save-dev )
update angular.json file by doing the following: replace this:
"server": { "builder": "@angular-devkit/build-angular:server", . . . }
to this
"server": { "builder": "@angular-builders/custom-webpack:server", }
update the options section in the server
"server": { "builder": "@angular-builders/custom-webpack:server", "options": { . . . "customWebpackConfig": { "path": "./webpack.config.js" } }
Now create a new file at the root of you app with name "webpack.config.js"
inside webpack.config.js add these
module.exports = { externals: ["_http_common", "encoding"], };
That's it. I hope this helps. happy coding!!!
Solution 2:[2]
Use webpack-node-externals:
webpack.config.js:
const nodeExternals = require('webpack-node-externals')
module.exports = {
...
externals: [ nodeExternals() ],
...
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Xraybrain |
| Solution 2 |
