Module not found: Error: Can't resolve 'crypto' in '/opt/lampp/htdocs/angular-testing-app/node_modules/jwa'
I faced the issue same as you and I resolved. You can follow these steps:
- Add this file to root directory
patch.js
const fs = require('fs');
const f = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';
fs.readFile(f, 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true}');
fs.writeFile(f, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
- Add this command to package.json file
package.json
{...
"scripts": {
"postinstall": "node patch.js",
...
}
}
Reference: https://gist.github.com/niespodd/1fa82da6f8c901d1c33d2fcbb762947d
But instead of using a pre-install, I just hand edited `node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js' and changed the lines in that regex:
// old:
node: false,
// new:
node: { crypto: true, stream: true },