Skip to content

ts-node doesn't work with latest typescript 2.5  #360

Closed

Description

@cevek

ts-node 1.tsx

TSError: ⨯ Unable to compile TypeScript
Cannot find type definition file for 'react'. (2688)
1.tsx (1,24): Cannot find module 'react'. (2307)

tsc works without problems

Activity

  1. blakeembrey commented on Jun 18, 2017

    @blakeembrey
    Member

    Can you give some example code that will replicate this? Can you verify your TypeScript versions aren't out of sync (e.g. you installed something locally but you're using the local version)?

  2. cevek commented on Jun 18, 2017

    @cevek
    ContributorAuthor

    create file 1.tsx

    import * as React from 'react';
    <div className="foo"></div>

    create file tsconfig.json

    {
      "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "jsx": "react"
      }
    }
    npm i -g ts-node
    npm i -g typescript@next
    npm init -y
    npm i @types/react 
    ts-node 1.tsx
    

    And result is

    /usr/local/lib/node_modules/ts-node/src/index.ts:300
            throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
                  ^
    TSError: ⨯ Unable to compile TypeScript
    Cannot find type definition file for 'react'. (2688)
    1.tsx (1,24): Cannot find module 'react'. (2307)
        at getOutput (/usr/local/lib/node_modules/ts-node/src/index.ts:300:15)
    
    
  3. cevek commented on Jun 18, 2017

    @cevek
    ContributorAuthor

    with typescript@2.4 works correctly

  4. cevek commented on Jun 18, 2017

    @cevek
    ContributorAuthor

    I think its related to this merge microsoft/TypeScript#12336

  5. blakeembrey commented on Jun 18, 2017

    @blakeembrey
    Member

    Thanks for this! I'll have to look next week, but until then feel free to investigate yourself and/or submit a PR.

  6. cevek commented on Jun 19, 2017

    @cevek
    ContributorAuthor

    Bug on the typescript side microsoft/TypeScript#16616

  7. cevek commented on Jun 20, 2017

    @cevek
    ContributorAuthor

    PR #366

  8. blakeembrey commented on Jun 21, 2017

    @blakeembrey
    Member

    Closed with #366, cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions