Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
madmikeross opened this issue Aug 25, 2015 · 0 comments
Closed

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

madmikeross opened this issue Aug 25, 2015 · 0 comments

Comments

@madmikeross
Copy link

Hi James, love your work on this loader and your blog posts on jsx with typescript, it's helped a ton!

Just being thorough in posting this here, I originally reported this as an issue to TypeScript (microsoft/TypeScript#4445) but was advised that it might not be their bug. As advised I have thrown it up on StackOverflow (http://stackoverflow.com/questions/32211875/webpack-typescript-cannot-find-file-node-modules-react-package-json) and cross posted the issue here and to WebPack's issue tracker (webpack/webpack#1393)

I had this working yesterday on a fresh npm install, but this morning after a fresh install I was out of luck. So I'm at a bit of a loss for what happened.

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!

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

No branches or pull requests

1 participant