Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load JSON file in vue.js with Typescript

I've created a vue.js with typescript app using vue-cli 3 and selecting the typescript option.

Now I'm trying to import a .json file:

import * as config from './config.json';

But keep getting the compiler error:

Version: typescript 
2.7.17:25, tslint 5.9.1 
Cannot find module './config.json'.

The config.json file is right next to the .ts that is trying to load it.

Is there any additional config I need to add to load .json with the vue-cli templates?

like image 643
Kong Avatar asked Dec 24 '22 09:12

Kong


1 Answers

Add "resolveJsonModule": true to your tsconfig.json

like image 111
Nurpeyis Kalbekov Avatar answered Jan 05 '23 10:01

Nurpeyis Kalbekov