“TS importar json” Respostas de código

Não é possível encontrar módulo ./data.json. Considere usar --Resolvejsonmodule para importar o módulo com a extensão .json

add to tsconfig.json

{
	...
    "resolveJsonModule": true
  }
}
DevPedrada

Importar JSON TypeScript

// add this in your tsconfig.json file:
{
  "compilerOptions": {
    "resolveJsonModule": true
  }
}
Frantic Flatworm

TS importar json

{
  ...,
  "compilerOptions": {
    ...
    "moduleResolution": "node", // add this line
    "resolveJsonModule": true	// add this line
  },
  "include": ["**/*.ts", "./**/*.json"] // add json path
}
Clever Cheetah

-ResolvejsonModule

declare module "*.json" {
  const value: any;
  export default value;
}
Salo Hopeless

Respostas semelhantes a “TS importar json”

Perguntas semelhantes a “TS importar json”

Mais respostas relacionadas para “TS importar json” em TypeScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código