ajv-formats icon indicating copy to clipboard operation
ajv-formats copied to clipboard

Cannot read properties of undefined (reading 'code')

Open ralyodio opened this issue 2 years ago • 3 comments



Cannot read properties of undefined (reading 'code')

TypeError: Cannot read properties of undefined (reading 'code')
    at addFormats (/home/ettinger/src/avenasea.com/avenasea-ui/node_modules/ajv-formats/dist/index.js:30:26)
    at Proxy.formatsPlugin (/home/ettinger/src/avenasea.com/avenasea-ui/node_modules/ajv-formats/dist/index.js:15:5)
    at [email protected]:8:12
	import Ajv from 'ajv';
	import addFormats from 'ajv-formats';

	const ajv = new Ajv({ allErrors: true, strictSchema: false });
	addFormats(ajv);

ralyodio avatar Jun 28 '22 05:06 ralyodio

@ralyodio faced the same issue. Found following workaround:

const instance = new Ajv();
    if (!instance.opts) {
        // @ts-ignore
        instance.opts = { code: {} };
    }
    const ajv = addFormats(instance);

It looks like node platform issue, all works fine on macOs and crashes on linux.

volnyansky avatar Jul 12 '22 10:07 volnyansky

This doesn't work on my Mac:

MacBook Pro (14-inch, 2021)
Chip: Apple M1 Pro

dipunm avatar Jul 13 '22 15:07 dipunm

The Same. Have these issues on my MacBook Pro (14-inch 2021), Chip: M1 Pro. Workaround helped

cheburan avatar Oct 16 '22 04:10 cheburan