2

I'm running typescript with create-react-app on a local machine for development purposes. I've gotten rid of the node_modules directory as it's not needed once my image installs the dependencies. The app is able to run when I start it, but I want to know if there's a way to ignore unnecessary typescript warnings that are surfacing because I don't have the node_modules in my working directory.

ie. [ts] Cannot find module 'react', [ts] JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.

1
  • Are you developing inside the image? What you are trying to do seems slightly odd, since npm / yarn will install dependencies in a subdirectory. I am not sure what goal you are trying to achieve by adding docker into this mix. Commented Feb 7, 2019 at 5:10

1 Answer 1

3

Those aren't "unnecessary typescript warnings": tsc is telling you that it doesn't know anything about the structure of, in this case, React, and so it can't do the job of actually checking your program. By deleting the node_modules directory you've broken Typescript.

This is easy to fix. Re-running yarn install or npm install will re-read your package.json file and bring back the dependencies that the Typescript compiler (and presumably your application!) needs to run.

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

Comments

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.