Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Module build failed: Error: File was not found in program #9

Closed
erkieh opened this issue May 3, 2015 · 22 comments
Closed

Module build failed: Error: File was not found in program #9

erkieh opened this issue May 3, 2015 · 22 comments

Comments

@erkieh
Copy link

erkieh commented May 3, 2015

I tried to add this typescript loader to the following sample project:
https://github.com/iam4x/isomorphic-flux-boilerplate
I get an error while running "npm run dev". I'm not sure how to proceed from here. The path in the error seems correct.

ERROR in ./app/components/orderEdit.ts
Module build failed: Error: File C:\i\app\components\orderEdit.ts was not found
in program
at State.emit (C:\i\node_modules\awesome-typescript-loader\dist\host.js:120:
23)
at C:\i\node_modules\awesome-typescript-loader\dist\index.js:92:42
at tryCatcher (C:\i\node_modules\awesome-typescript-loader\node_modules\blue
bird\js\main\util.js:24:31)
at Promise._settlePromiseFromHandler (C:\i\node_modules\awesome-typescript-l
oader\node_modules\bluebird\js\main\promise.js:454:31)
at Promise._settlePromiseAt (C:\i\node_modules\awesome-typescript-loader\nod
e_modules\bluebird\js\main\promise.js:530:18)
at Async._drainQueue (C:\i\node_modules\awesome-typescript-loader\node_modul
es\bluebird\js\main\async.js:182:12)
at Async._drainQueues (C:\i\node_modules\awesome-typescript-loader\node_modu
les\bluebird\js\main\async.js:187:10)
at Immediate.Async.drainQueues [as _onImmediate](C:inode_modulesawesome-
typescript-loadernode_modulesbluebirdjsmainasync.js:15:14)
at processImmediate as _immediateCallback
@ ./app/routes.jsx 31:13-46

@s-panferov
Copy link
Owner

@erkieh There are no orderEdit.ts file in https://github.com/iam4x/isomorphic-flux-boilerplate/tree/master/app/components. Have you forgotten to commit something?

@Ciantic
Copy link

Ciantic commented May 4, 2015

interesting, I'm getting same file not found errors even though they are in the path given by error message.

P.S. it though emits a file, but still gives error?

P.S.S. maybe this issue is Windows related?

C:\Projects\HTML5\model-validation-ghpages\src>cat C:\Projects\HTML5\model-validation-ghpages\src\index.ts
/// <reference path="./typings/react/react.d.ts" />

import * as R from 'react';

function main() {

}

main();

Full error stack with awesome-typescript-loader:

C:\Projects\HTML5\model-validation-ghpages\src>webpack -w
{ emitRequireType: true }
{ emitRequireType: true }
Hash: 0930616303c82cd8062b
Version: webpack 1.8.11
Time: 1005ms
       Asset     Size  Chunks             Chunk Names
    index.js  1.63 kB       0  [emitted]  index
index.js.map  1.43 kB       0  [emitted]  index
   [0] multi index 28 bytes {0} [built] [1 error]
    + 1 hidden modules

ERROR in ./index.ts
Module build failed: Error: File C:\Projects\HTML5\model-validation-ghpages\src\index.ts was not found in program
    at State.emit (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\awesome-typescript-loader\dist\host.js:120:23)
    at C:\Projects\HTML5\model-validation-ghpages\src\node_modules\awesome-typescript-loader\dist\index.js:92:42
    at tryCatcher (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\util.js:24:31)
    at Promise._settlePromiseFromHandler (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\promise.js:454:31)
    at Promise._settlePromiseAt (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\promise.js:530:18)
    at Async._drainQueue (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\async.js:182:12)
    at Async._drainQueues (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\async.js:187:10)
    at Async.drainQueues (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\awesome-typescript-loader\node_modules\bluebird\js\main\async.js:15:14)
    at process._tickCallback (node.js:419:13)
 @ multi index

@Ciantic
Copy link

Ciantic commented May 4, 2015

The plot thickens, it does not compile with regular typescript-loader either at the moment, error is different:

Stack trace with typescript-loader, not awesome one.

C:\Projects\HTML5\model-validation-ghpages\src>webpack
Hash: 181f712554d648152cf7
Version: webpack 1.8.11
Time: 617ms
         Asset     Size  Chunks             Chunk Names
    ./index.js  1.63 kB       0  [emitted]  index
./index.js.map  1.43 kB       0  [emitted]  index
   [0] multi index 28 bytes {0} [built] [1 error]
    + 1 hidden modules

ERROR in ./index.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getLength (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\lib\TypeScriptWebpackHost.js:65:18)
    at createLanguageServiceSourceFile (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:35738:97)
    at acquireOrUpdateDocument (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:35813:34)
    at Object.acquireDocument (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:35802:20)

    at Object.getOrCreateSourceFile [as getSourceFile] (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:36343:41)
    at findSourceFile (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:29061:62)
    at processSourceFile (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:29022:27)
    at C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:29101:17
    at Object.forEach (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:709:30)
    at processReferencedFiles (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:29099:16)

    at findSourceFile (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:29075:25)
    at processSourceFile (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:29022:27)
    at processRootFile (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:29008:13)
    at C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:28897:56
    at Object.forEach (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:709:30)
    at Object.createProgram (C:\Projects\HTML5\model-validation-ghpages\src\node_modules\typescript-loader\node_modules\typescript\bin\typescript.js:28897:12)
 @ multi index

@Ciantic
Copy link

Ciantic commented May 4, 2015

My configuration can't be simpler now:

webpack.config.js:

module.exports = {
    resolve: {
        extensions: ['', '.ts', '.js']
    },
    devtool: 'source-map',
    module: {
        loaders: [{
            test: /\.ts$/,
            loader: 'awesome-typescript-loader'
        }]
    },
    entry: {
        index: ['./index.ts']
    },
    output: {
        path: '../',
        filename: '[name].js'
    }
};

index.ts:

function main() {

}

Still same error. Maybe it is some Windows problem?

Versions

C:\...>webpack --help
webpack 1.8.11
Usage: http://webpack.github.io/docs/cli.html

C:\...>node -v
v0.12.2

@s-panferov
Copy link
Owner

@Ciantic thanks for the details. I will look at this issue tomorrow morning (GMT+3) from my PC with Windows.

@Ciantic
Copy link

Ciantic commented May 5, 2015

I'm now trying in fresh directory in shorter path, with same test files as above. Same error.

Edit tried with TypeScript 1.5-alpha too, same error. Currently default with npm is 1.5-beta.

@s-panferov
Copy link
Owner

@Ciantic yes, this is an error with backslashes on Windows. I'll fix this soon.

@Ciantic
Copy link

Ciantic commented May 5, 2015

seems like if I hack awesome-typescript-loader/dist/host.js with

        var source = this.program.getSourceFile(fileName); // About line 115 
        fileName = fileName.replace(/\\/g, "/"); // I added this line

Things start to work again.

@seburgi
Copy link

seburgi commented May 7, 2015

@Ciantic thanks, that fixed it for me too!

s-panferov added a commit that referenced this issue May 8, 2015
fix(*): fix windows path logic, fixes #9
@s-panferov
Copy link
Owner

@seburgi @Ciantic please try v0.3.0-rc.5 with the fix.

@raveclassic
Copy link

Looks like it is reproducible on Windows hosts again after update to 0.15...

typescript: 1.8.0-dev.20151123
awesome-typescript-looader: 0.15.3
babel-runtime: 6.0.14,

@s-panferov s-panferov reopened this Nov 25, 2015
@ghost
Copy link

ghost commented Nov 30, 2015

I just installed awesome-typescript-loader to see if this problem I had a month ago was fixed, and no.. I 'm having the same problem. awesome-typescript-loader is not recognising my internal files/modules starts with import something from './something' .

I'm using windows.

@GenZodd
Copy link

GenZodd commented Dec 14, 2015

Any update on this? Is a fix on the way? We are having the same issue. A little different in that we are wild-carding the selection of the TS files but we get the same error.

@aspirisen
Copy link

I have the same issue. For me, first of all, it depends on how many entry points I have (now I have 3). One of them is always compiled correctly and two of them are not. If I delete the succeeded entry point from the entries list the next will be compiled correctly and another one not. If I have only one entry point it is always compiled correctly.

Another option is if I use compiled files from Visual Studio with usePrecompiledFiles: true flag. It is always compiled correctly despite the entries quantity.

@s-panferov
Copy link
Owner

I will look through the issue today. Does anyone has a little example I can play with?

@labrute
Copy link

labrute commented Dec 17, 2015

I have the same issue.
You can use yeoman with gulp-angular generator with typescript, it will create an "sample" project.
Update the plugin version, and try.

With typescript 1.7.5 or 1.6.2
Windows
awesome-typescript-loader 0.15.0 to 0.15.9

@frapontillo
Copy link

I am having the same issue after upgrading to 0.15.9.

@musakarakas
Copy link

@frapontillo Same here. 0.15.8 also has the same issue. v0.15.7 works fine.
Apparently, 1715bee broke it.

@BHouwens
Copy link

@musakarakas +1 to this, 0.15.7 fixes the issue

@andrew-w-ross
Copy link

@musakarakas Looks like you're right 0.15.7 is the version to use.

@s-panferov
Copy link
Owner

Could you please try v0.15.10?

@musakarakas
Copy link

v0.15.10 works for me. No errors or warnings.
Thanks for the update @s-panferov.

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