does anyone have any experience importing json fil...
# typescript
does anyone have any experience importing json files in pulumi projects? I’m using AJV to do some config validation and have the following code:
Copy code
import * as pulumi from '@pulumi/pulumi';
import Ajv, { JTDDataType } from 'ajv/dist/jtd';
import repoConfigSchema from './config-schema.json';

// ...
however when running the program with
pulumi up
i get the following error:
Copy code
pulumi:pulumi:Stack (gh-repos-main):
    error: Running program '<redacted>/src' failed with an unhandled exception:
    TSError: ⨯ Unable to compile TypeScript:
    config.ts(3,30): error TS2732: Cannot find module './config-schema.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

        at createTSError (<redacted>/node_modules/ts-node/src/index.ts:261:12)
        at getOutput (<redacted>/node_modules/ts-node/src/index.ts:367:40)
        at Object.compile (<redacted>/node_modules/ts-node/src/index.ts:558:11)
        at Module.m._compile (<redacted>/node_modules/ts-node/src/index.ts:439:43)
        at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
        at Object.require.extensions.<computed> [as .ts] (<redacted>/node_modules/ts-node/src/index.ts:442:12)
        at Module.load (internal/modules/cjs/loader.js:950:32)
        at Function.Module._load (internal/modules/cjs/loader.js:790:14)
        at Module.require (internal/modules/cjs/loader.js:974:19)
        at require (internal/modules/cjs/helpers.js:92:18)
but i have enabled
in my tsconfig:
Copy code
  "$schema": "<>",
  "display": "Node 14",
  "compilerOptions": {
    "target": "es2020",
    "lib": [
    "module": "commonjs",
    "outDir": "dist/",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true
  "include": [
any ideas what I’m missing?
You might need
"moduleResolution": "node",
that didn't help, but i found the problem is related to me changing the
property in
. it seems to mess with module resolution in certain cases, this being one of them