Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Module build failed: Error: Cannot find module 'typescript' -- Missing dependency in package.json? #110

Closed
alshain opened this issue Jul 19, 2017 · 3 comments

Comments

@alshain
Copy link

alshain commented Jul 19, 2017

Description

After upgrading react-scripts-ts with npm install -D [email protected] 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:

  1. npm ls react-scripts-ts (if you haven’t ejected):

`-- [email protected]

  1. node -v: v7.7.4
  2. npm -v: 5.3.0

Then, specify:

  1. Operating system: Win 7 x86
  2. 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.

@wmonk
Copy link
Owner

wmonk commented Aug 8, 2017

As this issue hasn't been updated for a while, I am going to close it. If there are any updates feel free to re-open and comment. 👍

@wmonk wmonk closed this as completed Aug 8, 2017
@alshain
Copy link
Author

alshain commented Aug 9, 2017

Well, I was waiting for feedback from you, what updates did you expect? Is it correct that the generated package.json shouldn't contain a typescript dependency?

@nhustak
Copy link

nhustak commented Jan 19, 2018

Just wanted to add something I figured out on this issue. I was experiencing it suddenly on Angular 5 app that had been working. Lot of trial and error...it turns out that it was not happy I had a camel case ts file (vProperty.ts) OR that the add on I was using like to do a './../..' instead of '../..'. for the import Changing both of these and the problem went away.

However what is really strange...I still have a LOT of instances of this (which I am in the process of refactoring..that still work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants