Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript error importing vue package (vue-cli3 proj)

I have a project with newest dependencies set up wizth CLI 3. I get error when importing font-picker-vue package in my project (package installs successfully though).

The error: Could not find a declaration file for module 'font-picker-vue'......../node_modules/font-picker-vue/lib/FontPicker.js' implicitly has an 'any' type. Try npm install @types/font-picker-vue if it exists or add a new declaration (.d.ts) file containing declare module font-picker-vue';

Did a google search and one of the solution suggested was to add following code in a *.d.ts file: src

declare module 'vuetify/lib' {
  import 'vuetify/types/lib'
}

Created a *.d.ts file in the root of the proj as shown in below image, hoping that it would work, but it did not:

*.d.ts file in project directory

Next, as suggested SO reply changed import statements to require: const yourModuleName = require('module-name'); and also tried installing from npm install -D @types/font-picker-vue. Both didn't work, @types/font-picker-vue isn't in the npm registry.

I am not sure how to resolve this error. Can somebody help be get this working. Any help is apprecited. Thanks

like image 358
appu Avatar asked May 20 '26 09:05

appu


1 Answers

Create a yourModuleName.d.ts file with the module declaration like this declare module 'vuetify/lib' then try adding this:

"include": "*.d.ts"

To your tsconfig.json file

like image 166
Dennis Avatar answered May 22 '26 00:05

Dennis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!