-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Bug in AOT mode with Angular 5 when using yarn: TypeScript compilation failed #8107
Comments
Project example: https://github.com/quanterion/cli-aot-bug |
I have Angular-Cli installed via npm when I remove cli from npm and install via yarn it gives me more detailed error message when serving with ng serve --aot: ERROR in ./src/main.ts webpack: Failed to compile. TypeError: Cannot read property 'length' of undefined |
Same here. package.json
yarn.lock
Using npm only 2.4.2 is used and build --prod --aot works fine. |
... tested with npm 3.10.10, dunno about 5. Tired of yarn bugs 😪 edit: |
I'm experiencing the same error. This was happening on the 1.5.0 beta releases also, I just never filed an issue because I figured something was wrong on my end. yarn.lock has been my source of truth for awhile now, switching to npm scares me 😨 |
@Matmo10 same here, although npm‘s package lockfile seems tempting... |
It is not a Yarn bug anyhow. Hoisting is an implementation detail of the package manager (including Yarn) and if one wants to have single instance of some package, they should specify it as a peer dependency instead of a normal dependency. Expecting that package manager will always hoist it to the single instance is wrong. So the right fix here is probably to change cc @filipesilva PS There were several fixes in Yarn around peer dependencies resolution (yarnpkg/yarn#4433 and yarnpkg/yarn#4539) in recent versions, so I would recommend to use >=1.2.1 which contains all of them . |
We're aware of this problem but there actually is no non-breaking change that would fix it. It's not about the peer dependency on build-optimizer. Build optimizer doesn't need to use the same typescript as your project. It's about peer dependency that
So to prevent peer dependency errors/warnings This is wrong because, as @devoto13 said, to hoist or not is an implementation detail of the package manager. The right way to do it is with peer dependencies. But we can't do that until we split the global and local CLI installs. And that's a breaking change. So that's where we stand right now. There may be a couple of hacks we do to try to sort this out for now but they are hacks. |
Fixed by #8185 |
@filipesilva Thank you! I can indeed build now with the latest master, but I'm seeing the following warnings, are these expected or should another issue be raised?
|
While I can build, I can't run my Angular v5 app with the CLI code in master due to this error when loading the page in Chrome:
|
@Splaktar, were you able to fix that warning? |
@blingerson This is already fixed in the last release or 2 of 1.5.x |
@blingerson yes, it's fixed in one of the RCs after 3. Working in the |
I still have this error here, how do I correct it? '' Critical dependency: the request of a dependency is an expression |
@ThalesMatoso
|
@SFDanny thank you, but this is not resolve my problem, after search on much on web, i discovered that it was error on library ngx-mask. following on issue for more details. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug when using AOT with Angular 5
Versions.
Yarn: 1.2.1
Angular CLI: 1.5.0-rc.1
Node: 8.4.0
OS: win32 x64
Angular: 5.0.0-rc.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
angular/cli: 1.5.0-rc.1
angular-devkit/build-optimizer: 0.0.28
angular-devkit/core: 0.0.20
angular-devkit/schematics: 0.0.34
ngtools/json-schema: 1.1.0
schematics/angular: 0.0.46
typescript: 2.4.2
webpack: 3.7.1
Repro steps.
The log given by the failure.
ERROR in ./src/main.ts
Module build failed: Error: TypeScript compilation failed.
at plugin.done.then (X:\ng15y\node_modules@angular\cli\node_modules@ngtools\webpack\src\loader.js:479:27)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
ERROR in ./src/polyfills.ts
Module build failed: Error: TypeScript compilation failed.
at plugin.done.then (X:\ng15y\node_modules@angular\cli\node_modules@ngtools\webpack\src\loader.js:479:27)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
@ multi ./src/polyfills.ts
ERROR in
Mention any other details that might be useful.
I use yarn 1.2.1 to install dependencies. I couldn't reproduce this error in empty project with npm 5, but after installing libraries material-beta.12, covalent-beta.8-1 and angulartics-2.4.0 the same problem also appears.
Reverting project to Angular 4.4.5 fixes this issue in both cases.
The text was updated successfully, but these errors were encountered: