Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when use in angular 16 #183

Open
MarianoFranzese opened this issue Dec 21, 2023 · 2 comments
Open

Error when use in angular 16 #183

MarianoFranzese opened this issue Dec 21, 2023 · 2 comments

Comments

@MarianoFranzese
Copy link

I have this error in console when in an angular service:

ERROR Error: Uncaught (in promise): ReferenceError: process is not defined

this is the code

import { Injectable } from '@angular/core';
import Ajv, { ErrorObject } from 'ajv';
import betterAjvErrors from 'better-ajv-errors';
import { geoJsonSchema } from './geojson.schema'; // the json schema

@Injectable({
  providedIn: 'root',
})
export class GeojsonValidationService {
  private ajv: Ajv;

  constructor() {
    this.ajv = new Ajv();
  }

  validateJson(data: any, schema: object = geoJsonSchema): boolean {
    const validate = this.ajv.compile(schema);
    const valid = validate(data);

    if (!valid) {
      const errors: ErrorObject[] = validate.errors || [];
      const output = betterAjvErrors(schema, data, errors);
      console.log('output => ', output);

    }
    
    return valid;
}

the versions that i use are:

 "@angular/core": "^16.2.12",
 [...]
 "ajv": "^8.12.0",
 "better-ajv-errors": "^1.2.0",
@sonjaka
Copy link

sonjaka commented Jan 18, 2024

I'm getting the same error. Did your find any solution to this problem?

@GoldraK
Copy link

GoldraK commented Feb 24, 2024

I have the same problem in vue3 with vite.

Add this to the vite config to fix

    define: {
        'process.env': {}
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants