I installed Axios local to my Typescript project, but generate an error when trying to import it. Error: "Cannot Find module axios".
root folder
npm install --save-dev axios
src/app.ts
import axios from 'axios';
package.json
"devDependencies": {
"axios": "^0.21.1",
It has something to do with my tsconfig.json. If I remove this file, axios is known. If I restore this file, the error comes back in VS Code. I know for Lodash package there is a Lodash types (https://www.npmjs.com/package/@types/lodash) to make lodash compatible with typescript. Is there an equivelent for axios?
I have this file .\node_modules\axios\index.d.ts that is supposed to help me out with typescript compatibility. Somehow it's not working.
This seems to help. It lets TS understand Axios. Even though Axios was supposed to work out of the box.
npm install --save @types/axios
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With