Module build failed: Error: Cannot find module 'typescript' -- Missing dependency in package.json? #110
Description
Description
After upgrading react-scripts-ts with npm install -D react-scripts-ts@2.4.0
from 2.2.0
, I get an error when compiling using npm start
Expected behavior
I expect things to work :)
Actual behavior
I get Module build failed: Error: Cannot find module 'typescript'
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts-ts
(if you haven’t ejected):
`-- react-scripts-ts@2.4.0
node -v
: v7.7.4npm -v
: 5.3.0
Then, specify:
- Operating system: Win 7 x86
- Browser and version: irrelevant
Suspected cause and how I fixed it:
Eventually, I fixed it by installing the typescript
module locally.
I initialized a new sample project with create-react-app. I noticed that it contained a locally installed typescript
module. However, said module was not listed in the freshly generated package.json
.
After running npm install -S typescript
, things started working again.
Related: #106 but deleting node_modules and re-running npm install
didn't fix things for me. Having typescript installed globally didn't help either.