sindresorhus/parse-json

ReferenceError: process is not defined when using with TS in Angular

BernhardFuchs opened this issue · 3 comments

When creating a function like the following:

import * as _parseJson from 'parse-json';

export function parseJson(json: string): string {
  return _parseJson(json);
}

And calliing it from an Angular service like this:

parseJson(someJson)

results in above error.

The error points to following line:

const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');

Versions:

  • Angular: 8.1.1
  • parse-json: 5.0.0

That is a problem with the Angular build tool. This package works fine in Node.js.

facing same issue with node vue.js

but not in v4.0.0