hammies
hammies

Reputation: 1455

angular ssr require is not a function

Trying to run npm run dev:ssr on angular/ionic, it is giving me the following error. How do I go about this?

server\main.js:306
var crypto = require('crypto');
             ^
TypeError: require is not a function

tsconfig

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": ["node"],
    "lib": [
      "es2018",
      "dom"
    ],
    "paths": {
      "crypto": [
        "node_modules/crypto-browserify"
      ]
    }
  }
}

Upvotes: 0

Views: 190

Answers (1)

Sarvesh Dubey
Sarvesh Dubey

Reputation: 44

try to replace var crypto = require('crypto'); to import * as Crypto from "plugin_name"; syntax

Upvotes: 0

Related Questions