0

I have a React project with Typescript. One day I create a javascript file in src/ and then my React app failed to start on localhost. Any explanation about this would be appriciated.
Evironment: Node 16.13.1
Step to reproduce:

git clone [email protected]:manaclan/fun-pms-frontend.git
cd fun-pms-frontend
git checkout vinhngo

Inside package.json remove:

"@types/react-facebook-login": "^4.1.4"
"react-facebook-login": "^4.1.1"

Then npm install and npm start will notify that localhost:3000 failed to connect. Removing src/setupProxy.js will make the server start as normal

1 Answer 1

1

That's because JavaScript is not allowed in Typescript projects, you would need to modify your Typescript config, add the following flag to to the config file

--allowJs

Depending on the module bundler you probably also have to set the output directory for the transpiled Typescript files.

Sign up to request clarification or add additional context in comments.

2 Comments

tks for the response but can you provide some reference links about this ?
Sorry here is some reference typescriptlang.org/tsconfig/allowJs.html . What exactly is the error? Maybe there is another reason, I only suggested this, because I also had some issues regarding js inside of ts project and that solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.