SyntaxError: strict mode code may not contain 'with' statements after 8 -> 9 upgrade (Hello World)
See original GitHub issue🐞 bug report
Affected Package
Not clear to me, the vendor.js link in the screenshot below points to `/node_modules/domino/lib/sloppy.js`Is this a regression?
Yes, upgrades from 7->8 work fine. 8->8.x also workDescription
If I scaffold a Hello World application using `dotnet new angular -o my-new-app`, then I upgrade to Angular 9, I get the above error in the Console: `SyntaxError: strict mode code may not contain 'with' statements` and the Hello World page is stuck on `Loading...`🔬 Minimal Reproduction
- dotnet new angular -o my-new-app
- cd my-new-app/ClientApp/
- npm install
- ng serve verify Hello World Angular 8 app works here
- ng update @angular/core@8 @angular/cli@8
- ng update @angular/cli @angular/core --next
- ng serve Hello World does not work
I did the above instructions on this git repo, and you can run ng serve
here: https://github.com/dmbaker90/Angular_9_bug
🔥 Exception or Error
🌍 Your Environment
Angular Version:
$ ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 9.0.0-rc.10
Node: 12.14.1
OS: win32 x64
Angular: 9.0.0-rc.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes
Package Version
--------------------------------------------------------------------
@angular-devkit/architect 0.900.0-rc.10
@angular-devkit/build-angular 0.900.0-rc.10
@angular-devkit/build-optimizer 0.900.0-rc.10
@angular-devkit/build-webpack 0.900.0-rc.10
@angular-devkit/core 9.0.0-rc.10
@angular-devkit/schematics 9.0.0-rc.10
@angular/cli 9.0.0-rc.10
@ngtools/webpack 9.0.0-rc.10
@nguniversal/module-map-ngfactory-loader 8.1.1
@schematics/angular 9.0.0-rc.10
@schematics/update 0.900.0-rc.10
rxjs 6.5.3
typescript 3.7.5
webpack 4.41.2
Anything else relevant?
It wasn’t clear to me if this was a dotnet issue or angular issue. ng new
projects seem to work fine. However, I don’t see why the dotnet scaffolding would be related to npm package updates.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Uncaught SyntaxError: Strict mode code may not include a ...
I was searching for the solution to a similar problem. Upgrade to Angular 9 broke my app. After a lot of trial and...
Read more >JavaScript Strict Mode Code may not Contain with Statements
Live Demo: JavaScript Strict Mode Code may not Contain with Statements. Note: Please check out the browser console by pressing the f12 key...
Read more >Hello World | Mastering JavaScript - Packt Subscription
A constant cannot change the value through assignment or be redeclared, and it has to be initialized to a value. JavaScript supports the...
Read more >NaN - JavaScript - MDN Web Docs
The global NaN property is a value representing Not-A-Number.
Read more >Strict Mode - React
StrictMode is a tool for highlighting potential problems in an application. Like Fragment , StrictMode does not render any visible UI.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, I have looked at the repo and it seems that the root cause seems to be that your browser bundle is including
domino
which shouldn’t not happen.The browser bundle is including
@angular/platform-server
which importsdomino
due to https://github.com/dmbaker90/Angular_9_bug/blob/a531d61134a4291d4af8305d9b9098fd97bcd117/my-new-app/ClientApp/src/main.ts#L22That export was added with an Angular CLI version 9 migration, the reason for this is because the server main file is pointing to same one as the browser. Typically the server and browser builds have separate entrypoints because of different dependencies and are commonly named
main.server.ts
andmain.ts
. https://github.com/dmbaker90/Angular_9_bug/blob/a531d61134a4291d4af8305d9b9098fd97bcd117/my-new-app/ClientApp/angular.json#L97It seems that there is a bug in scaffolding of the new application with dotnet templates. I also tried using NET Core 2.2 SDK version 2.2 (current latest) and it is still using Angular CLI version 6 (Which is no longer in LTS) to scaffold application.
Remove the below from your
main.ts
If you are not using Angular universal you should also remove the
server
section in yourangular.json
, since it is incorrect and might cause future problems.Jason Taylor wrote a very good article to this theme: https://jasontaylor.dev/asp-net-core-angular-9-upgrade/