Skip to content

Could not find file /react/package.json #4445

Closed
@madmikeross

Description

@madmikeross

I am using typescript@next with webpack and ts-loader.

When running Webpack I am receiving the following error from typescript.js:43445

C:\Users\Michael\Development\Replicate>webpack
Using config file at C:\Users\Michael\Development\Replicate\tsconfig.json
C:\Users\Michael\Development\Replicate\node_modules\typescript\lib\typescript.js:43445
                throw new Error("Could not find file: '" + fileName + "'.");
                      ^
Error: Could not find file: 'C:/Users/Michael/Development/Replicate/node_modules/react/package.json'.
    at getValidSourceFile (C:\Users\Michael\Development\Replicate\node_modules\typescript\lib\typescript.js:43445:23)
    at Object.getSyntacticDiagnostics (C:\Users\Michael\Development\Replicate\node_modules\typescript\lib\typescript.js:43615:52)
    at C:\Users\Michael\Development\Replicate\node_modules\ts-loader\index.js:186:42
    at Array.forEach (native)
    at Compiler.<anonymous> (C:\Users\Michael\Development\Replicate\node_modules\ts-loader\index.js:185:14)
    at Compiler.applyPlugins (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\tapable\lib\Tapable.js:26:37)
    at Compiler.<anonymous> (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:193:12)
    at Compiler.emitRecords (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:282:37)
    at Compiler.<anonymous> (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:187:11)
    at C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:275:11
    at Compiler.applyPluginsAsync (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\tapable\lib\Tapable.js:60:69)
    at Compiler.afterEmit (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:272:8)
    at Compiler.<anonymous> (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:267:14)
    at C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\async\lib\async.js:52:16
    at done (C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\async\lib\async.js:248:21)
    at C:\Users\Michael\AppData\Roaming\npm\node_modules\webpack\node_modules\async\lib\async.js:44:16
    at FSReqWrap.oncomplete (fs.js:95:15)

my package.json

{
  "name": "Replicate",
  "version": "1.0.0",
  "description": "Reproducing typescript file not found bug",
  "main": "webpack.config.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Michael Ross",
  "license": "MIT",
  "dependencies": {
    "react": "^0.13.3",
    "ts-loader": "^0.5.0",
    "typescript": "^1.6.0-dev.20150825"
  }
}

my webpack.config.js

module.exports = {
    entry: "./app.tsx",
    output: {
        filename: "bundle.js"
    },
    resolve: {
        extensions: ["", ".tsx", ".ts", ".js"]
    },
    module: {
        loaders: [
            { test: /\.ts(x?)$/, loader: "ts-loader" }
        ]
    }
}

my app.tsx

import React = require('react');

class Demo extends React.Component<any, any> {
    render() {
        return <div>Trying to replicate</div>
    }
}

React.render(<Demo />, document.getElementById("demo"));

and just in case, my tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "jsx": "react",
        "sourceMap": true
    },
    "files": [
        "./typings/tsd.d.ts",
        "./app.tsx"
    ]
}

and tsd.json

{
  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "master",
  "path": "typings",
  "bundle": "typings/tsd.d.ts",
  "installed": {
    "react/react.d.ts": {
      "commit": "71a7d5306ae4f9893aafd2d85d38aac8789ebf33"
    }
  }
}

If I have a configuration error, help and guidance is much appreciated. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions