Skip to content

ng build: specifying output path explicitly breaks aot #2538

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

Closed
Meligy opened this issue Oct 6, 2016 · 11 comments
Closed

ng build: specifying output path explicitly breaks aot #2538

Meligy opened this issue Oct 6, 2016 · 11 comments
Assignees
Labels
needs: more info Reporter must clarify the issue P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix

Comments

@Meligy
Copy link
Contributor

Meligy commented Oct 6, 2016

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Windows 8.1 x64

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.16
node: 4.4.2
os: win32 x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

A pretty fresh app created by CLI

ng build -prod --aot works

ng build -o dist -prod --aot breaks

``

The log given by the failure.

Normally this include a stack trace and some more information.

Output

 12% building modules 19/29 modules 10 active ...tform-browser\src\platform-browser.jsModuleNotFoundError: Module not found: Error: Can't resolve './../D:/client/dist/ngfactory/src/app/app.module.ngfactory' in 'D:\client\src'
    at D:\client\node_modules\webpack\lib\Compilation.js:229:38
    at onDoneResolving (D:\client\node_modules\webpack\lib\NormalModuleFactory.js:29:20)
    at D:\client\node_modules\webpack\lib\NormalModuleFactory.js:94:20
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:726:13
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:52:16
    at done (D:\client\node_modules\webpack\node_modules\async\lib\async.js:241:17)
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:44:16
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:723:17
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:167:37
    at D:\client\node_modules\webpack\lib\NormalModuleFactory.js:89:22
    at onResolved (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:70:11)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at D:\client\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:39:4
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:123:11)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at D:\client\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:45:5
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at next (D:\client\node_modules\tapable\lib\Tapable.js:115:11)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:123:11)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at D:\client\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:45:5
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at Resolver.<anonymous> (D:\client\node_modules\enhanced-resolve\lib\FileExistsPlugin.js:23:12)
    at Storage.finished (D:\client\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:39:16)
    at D:\client\node_modules\enhanced-resolve\node_modules\graceful-fs\polyfills.js:264:29
    at FSReqWrap.oncomplete (fs.js:82:15)
resolve './../D:/client/dist/ngfactory/src/app/app.module.ngfactory' in 'D:\client\src'
  using description file: D:\client\package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: D:\client\package.json (relative path: ./src)
    using description file: D:\client\package.json (relative path: ./D:/client/dist/ngfactory/src/app/app.module.ngfactory)
      as directory
        D:\client\D:\client\dist\ngfactory\src\app\app.module.ngfactory doesn't exist
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        D:\client\D:\client\dist\ngfactory\src\app\app.module.ngfactory doesn't exist
      Field 'browser' doesn't contain a valid alias configuration
      D:\client\D:\client\dist\ngfactory\src\app\app.module.ngfactory doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        D:\client\D:\client\dist\ngfactory\src\app\app.module.ngfactory.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        D:\client\D:\client\dist\ngfactory\src\app\app.module.ngfactory.js doesn't exist

D:\client\node_modules\webpack\lib\Compiler.js:192
                                        if(err) return callback(err);
                    ^
TypeError: Cannot read property 'hash' of undefined
    at D:\client\node_modules\angular-cli\tasks\build-webpack.js:38:26
    at Compiler.onCompiled (D:\client\node_modules\webpack\lib\Compiler.js:192:21)
    at Compiler.<anonymous> (D:\client\node_modules\webpack\lib\Compiler.js:432:18)
    at D:\client\node_modules\tapable\lib\Tapable.js:148:11
    at Compilation.<anonymous> (D:\client\node_modules\webpack\lib\Compilation.js:435:11)
    at D:\client\node_modules\webpack\lib\Compilation.js:417:13
    at D:\client\node_modules\webpack\lib\Compilation.js:329:11
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:52:16
    at done (D:\client\node_modules\webpack\node_modules\async\lib\async.js:241:17)
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:44:16
    at D:\client\node_modules\webpack\lib\Compilation.js:329:11
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:52:16
    at done (D:\client\node_modules\webpack\node_modules\async\lib\async.js:241:17)
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:44:16
    at errorAndCallback (D:\client\node_modules\webpack\lib\Compilation.js:199:5)
    at errorOrWarningAndCallback (D:\client\node_modules\webpack\lib\Compilation.js:225:13)
    at D:\client\node_modules\webpack\lib\Compilation.js:229:12
    at onDoneResolving (D:\client\node_modules\webpack\lib\NormalModuleFactory.js:29:20)
    at D:\client\node_modules\webpack\lib\NormalModuleFactory.js:94:20
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:726:13
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:52:16
    at done (D:\client\node_modules\webpack\node_modules\async\lib\async.js:241:17)
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:44:16
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:723:17
    at D:\client\node_modules\webpack\node_modules\async\lib\async.js:167:37
    at D:\client\node_modules\webpack\lib\NormalModuleFactory.js:89:22
    at onResolved (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:70:11)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at D:\client\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:39:4
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:123:11)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at D:\client\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:45:5
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at next (D:\client\node_modules\tapable\lib\Tapable.js:115:11)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:123:11)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at D:\client\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:45:5
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at afterInnerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:138:10)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (D:\client\node_modules\tapable\lib\Tapable.js:108:46)
    at innerCallback (D:\client\node_modules\enhanced-resolve\lib\Resolver.js:125:19)
    at loggingCallbackWrapper (D:\client\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19)
    at D:\client\node_modules\tapable\lib\Tapable.js:210:15
    at Resolver.<anonymous> (D:\client\node_modules\enhanced-resolve\lib\FileExistsPlugin.js:23:12)
    at Storage.finished (D:\client\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:39:16)
    at D:\client\node_modules\enhanced-resolve\node_modules\graceful-fs\polyfills.js:264:29
    at FSReqWrap.oncomplete (fs.js:82:15)

With the project created at D:\client in that case (actual path shortened to not include private info, it takes forever to redo npm install on the current network to run another ng new).

Mention any other details that might be useful.

Note that I didn't even change the folder, I started setting outDir explicitly in my scripts because of #2511.


Thanks! We'll be in touch soon.

@Meligy
Copy link
Contributor Author

Meligy commented Oct 6, 2016

There are a few instances where it seems to be confused about relative and absolute paths:

 12% building modules 19/29 modules 10 active ...tform-browser\src\platform-browser.jsModuleNotFoundError: Module not found: Error: Can't resolve './../D:/client/dist/ngfactory/src/app/app.module.ngfactory' in 'D:\client\src'

and

resolve './../D:/client/dist/ngfactory/src/app/app.module.ngfactory' in 'D:\client\src'
  using description file: D:\client\package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: D:\client\package.json (relative path: ./src)
    using description file: D:\client\package.json (relative path: ./D:/client/dist/ngfactory/src/app/app.module.ngfactory)

and

        Field 'browser' doesn't contain a valid alias configuration
        D:\client\D:\client\dist\ngfactory\src\app\app.module.ngfactory doesn't exist

I'm guessing Windows is sending absolute path to the CLI even when writing just folder name, and the CLI is expecting relative path. That, or something else is screwing up the path in some step deep in the CLI, which in this case may or may not be OS specific.

Update:

Escaping the parameter though, like sending it with quotes "dist" or "./dist" doesn't seem to help, so it might not be an arguments reading problem.

@coryrylan
Copy link
Contributor

Replicated the same issues as well on
Windows 10 x64
CLI Beta 16

@achimha
Copy link

achimha commented Oct 6, 2016

Got the same issue on macOS Sierra and beta 16.

@michaelbromley
Copy link

I think I am running into a permutation of this issue when using the webpack plugin (NgcWebpackPlugin).

My app is does not use a folder named "app", so I get the can't resolve... error when I rely on the genDir setting in tsconfig.json. Setting genDir in the plugin options in webpack.config.js seems to fis it.

Looks like it is due to this line.

@Meligy
Copy link
Contributor Author

Meligy commented Oct 7, 2016

@michaelbromley that's very super interesting. I wonder if this is the case, why does it work when the folder name is not stated explicitly then, even in prod mode.

The following command works just fine: npm build -prod --aot.

@filipesilva filipesilva added type: bug/fix command: build P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful labels Oct 9, 2016
@filipesilva filipesilva self-assigned this Oct 9, 2016
@filipesilva
Copy link
Contributor

filipesilva commented Oct 9, 2016

This sounds like a aot bug (unrelated to #2511), but in beta.16 the aot plugin was still very experimental. Can you try in beta.17? Path resolution should be improved.

I just tried ng build -o dist -prod --aot myself and it seemed to be fine.

@filipesilva filipesilva added the needs: more info Reporter must clarify the issue label Oct 9, 2016
@Meligy
Copy link
Contributor Author

Meligy commented Oct 11, 2016

Works fine on beta-17

Tested on:

Windows 10 x64
Node: v6.6.0
NPM: 3.10.3

Unless there was something related to Node 4.4.2, this should be good. I'll close it for now.

Thanks @filipesilva for all the awesome work on the CLI, and still being present to take care of these many issues.

@Meligy Meligy closed this as completed Oct 11, 2016
@valorkin
Copy link
Contributor

valorkin commented Oct 21, 2016

from time to time I can see this issue >.<
-prod flag doesn't help me

angular-cli: 1.0.0-beta.18
node: 6.9.1
os: linux x64

PS: running ngc creates required files
but issues is raised anyway

@ghost
Copy link

ghost commented Nov 13, 2016

It seems on my mac having the latest node version (7.1.0) will still work fine with Angular CLI, but when I tried this with a make, I had to uninstall my node and get the other node version which was the (6.9.1) to work since the (7.1.0) wasn't doing it for me on the windows 10 machine.

@Meligy
Copy link
Contributor Author

Meligy commented Nov 13, 2016

@justsandytran Node 7 is a problem for so many NPM packages. Several super popular packages depend on a version of fs-events that's outdated and incompatible with Node 7.

Furthermore, the official recommendation for stable environments is to use the latest Long Term Support (LTS) release, which is still Node 6.x.

Cheers,

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix
Projects
None yet
Development

No branches or pull requests

6 participants