Reputation: 922
Cannot compile after using fast-image-size node module. I tried serveral steps to slove this but nothis helped. Finally I add "types": ["ts-node"],
to tsconfig.js file , but not helped. How do I solve this??
My typescript version is 3.7.3 .
Upvotes: 3
Views: 7453
Reputation: 559
You can
declare var require: any
Also instead of var fast_image_size = require('../index.js')
you could try the following:
import fast_image_size from '../index.js' // or
import fast_image_size = require('../index.js')
Upvotes: 5
Reputation: 1884
You're receiving this error because this is not how TypeScript handles file imports. TypeScript handles importing or including files in a slightly different manner. To resolve this:
-Remove line 198 ("var fast_image_size = require("..index.js");")
-Instead, at the top of the file add the following line:
import * as fast_image_size from '..index.js'
The rest of your script should then compile.
Upvotes: 1