Angular 4 Universal Node.js server.js Error

261 Views Asked by At

I'm building an Angular 4 CLI app and trying to do SSR using the new builtin Universal. All seems to work fine until I try to run node server.js

The below error is returned:

var crypto = require('crypto');
             ^
TypeError: require is not a function
    at Object.webpackEmptyContext.keys (/dist-server/server.js:156480:14)
    at __webpack_require__ (/dist-server/server.js:20:30)
    at Object.<anonymous> (/dist-server/server.js:156469:20)
    at __webpack_require__ (/dist-server/server.js:20:30)
    at Object.module.exports.raw (/dist-server/server.js:42461:18)
    at __webpack_require__ (/dist-server/server.js:20:30)
    at Object.<anonymous> (/dist-server/server.js:42340:15)
    at __webpack_require__ (/dist-server/server.js:20:30)
    at Object.<anonymous> (/dist-server/server.js:77201:22)
    at __webpack_require__ (/dist-server/server.js:20:30)

Any Angular 4 Universal experts out there?

0

There are 0 best solutions below