I\'m building an Angular 6 app, but every time I want to serve to localhost, I get these errors:
ERROR in ./node_modules/aws-sign2/index.js
Module not found
You can user patch file solve this problem.
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);
});
});
package.json
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "node patch.js && ng build",
"build-prod": "node patch.js && ng build --configuration=production",
"build-staging": "node patch.js && ng build --configuration=staging"
}
make sure to "build" the code before ng serve
only for the first time.