简体   繁体   中英

index.tsx in package react-router has 152 problems

Everything seems to work fine, I just see those errors. Is this normal? How can i fix this. My react application is written in Javascript, not in Typescript, but I do not think that this should matter, should it?

在此处输入图像描述

Are you using a package manager like npm/yarn/pnpm for installing react-router? Looking at that pathname it kinda looks like you're not and you should be.

If you're trying to import the index.tsx file directly in your JavaScript it won't work, you'll need the transpiled version which would be available automatically by installing it through a package manager (something like npm install react-router ). The plain js files would then be available under node_modules/react-router in the root directory of your project.

To import it somewhere in a React project you could then use:

import { Route } from 'react-router'

(no need for the full path name including node_modules - more info on npm install here: https://docs.npmjs.com/cli/v6/commands/npm-install )

I just restartet visual studio code and the errors disappeared.

For context, i had Visual studio running for some days now, so I can see how this could lead to some bugs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM