What to do if an error occurs when doing npm install axios in React + Typescript project

error contents

TypeScript error in / Users / /Public/workspace/todoapp/src/App.tsx(1,19): Could not find a declaration file for module'react'.' / Users / /Public/workspace/todoapp/node_modules/react/index.js' implicitly has an'any' type. If the 'react' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react` TS7016

App.tsx


  > 1 | import React from "react";
      |                   ^
    2 | import "./App.css";
    3 | import Api from "./components/Api";
    4 | 

approach

If you install it with yarn instead of npm, it works fine.

$yarn add axios 

Finally

I couldn't understand why it didn't work on npm. If you know the cause, please let us know. If you have an edit request, I will add the cause.

Recommended Posts

What to do if an error occurs when doing npm install axios in React + Typescript project
What to do and how to install when an error occurs in DXRuby 1.4.7
What to do if an error occurs when nokogiri enters when bundle install
What to do if an ActionController :: UnknownFormat error occurs
What to do if an error occurs in VS Code when importing a django module or your own module installed by pip install
What to do when an UnsupportedCharsetException occurs in a lightweight JRE
Add gem'rails-i18n','~> 6.0.0' and what to do if bundle install gives an error
no space left on device What to do if an error occurs
What to do when IllegalStateException occurs in PlayFramework
What to do if you get an error when you hit Heroku logs
What to do if you get an error with bundle install by entering gem'bcrypt' in your Gemfile
What to do if ffi installation fails when launching an application in Rails
What to do if ClassNotFoundException occurs when starting Tomcat
What to do when javax.batch.operations.JobStartException occurs
What to do if a SAX Parser error occurs when using Liferay 7 / DXP on AWS
What to do if you get an error in Basic authentication during Rails test code
What to do when an error occurs in rails db: migrate ((StandardError: An error has occurred, this and all later migrations canceled :))
What to do if you get a gcc error in Docker
What to do if you get a DISPLAY error in gym.render ()
[Programming beginner] What to do when rails s becomes an error in the local development environment
What to do if an SSH key authentication error occurs during automatic deployment to EC2 with Capistrano
What to do if you get a JNI shared library error when trying to build in Eclipse
What to do if you get an [An HTTP request took too long to complete.] Error in Docker.
What to do when a javax.el.PropertyNotWritableException occurs
What to do if you install Ubuntu
What to do if you get an error during rails db: reset
What to do when "npm ERR! Code ENOSELF" is displayed after npm install
What to do if you get an uninitialized constant Likes Controller error
What to do if tomcat process remains when tomcat is stopped in eclipse
Notes on what to do when a WebView ClassNotFoundException occurs in JavaFX 12
What to do if you should have installed Rails but an error occurs with rails -v (for beginners)
What to do if you get an error saying Cannot find a valid baseurl for repo when you use yum -y install docker in a udemy course using CentOS7
What to do if you get an error on heroku rake db: migrate
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if Command line is too long appears when building a gradle project in Intellij IDEA
After installing'devise''bootstrap' of gemfile with rails, what to do when url is an error
[Java] What to do if you get an error in Eclipse saying "Not allowed at source level below 1.X"
What to do if you can't get the text of an element in Selenium
What to do if you get an Argument Error: wrong number of arguments (given 2, expected 0) in your RSpec test
What to do if you get an error saying "Please enter a valid value" when getting with Rails datetime_field
What to do if Failure / Error: require File.expand_path ('../ config / environment', __dir__) appears in RSpec
What to do if you get the error Couldn't find Item without an ID
What to do if password authentication fails in Docker/Postgres
What to do if you get a port error when docker-compose up on Mac
What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server
What to do when an error (StandardError: An error has occurred, this and all later migrations canceled:) appears in rails db: migrate
<Dot installation> What to do if you cannot proceed due to an error when building a development environment for Rails learning.
What to do if you don't see the test code error message in the terminal console
[Rails] What to do if you accidentally install bundle in the production environment in your local environment
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
[Rails] What to do if you can't get an error message with the errors method
What to do if you get a "302" error in your controller unit test code in Rails
[Rails 6] What to do when a missing a template error occurs after introducing haml [Super easy]
What to do if you get a java.io.IOException in GlassFish
What to do when Method not found in f: ajax
What to do when you launch an application with rails
An error occurs when codedeploy-agent is installed in Ubuntu Server 20.04
[Rails] What to do when the error No database selected and Unknown database appears in db: migrate
A memo of the update command when npm install causes an error in GitHub Action etc.
What to do if you go offline due to SSL certificate error when running Jenkins on Mac
[Spring Boot] What to do if an HttpMediaTypeNotAcceptableException occurs on an endpoint for which produces is set