I'm trying to upgrade from Angular 8 to 9 and I'm getting this error when I do ng build. It looks like the problem is in the babel package in vendor.js.
[error] SyntaxError: C:\Dev\allverse3\ClientApp\vendor-es2015.js: 'with' in strict mode (139204:4)
[0m [90m 139202 | [39m [33mWindow_run[39m[33m:[39m [36mfunction[39m _run(code[33m,[39m file) {[0m
[0m [90m 139203 | [39m [36mif[39m (file) code [33m+=[39m [32m'\n//@ sourceURL='[39m [33m+[39m file[33m;[39m[0m
[0m[31m[1m>[22m[39m[90m 139204 | [39m [36mwith[39m([36mthis[39m) eval(code)[33m;[39m[0m
[0m [90m | [39m [31m[1m^[22m[39m[0m
[0m [90m 139205 | [39m }[33m,[39m[0m
[0m [90m 139206 | [39m [33mEventHandlerBuilder_build[39m[33m:[39m [36mfunction[39m build() {[0m
[0m [90m 139207 | [39m [36mtry[39m {[0m
at Parser.raise (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:7017:17)
at Parser.parseWithStatement (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11174:12)
at Parser.parseStatementContent (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10763:21)
at Parser.parseStatement (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10690:17)
at Parser.parseBlockOrModuleBlockBody (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11264:25)
at Parser.parseBlockBody (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11251:10)
at Parser.parseBlock (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11235:10)
at Parser.parseFunctionBody (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10252:24)
at Parser.parseFunctionBodyAndFinish (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10222:10)
at C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11394:12
at Parser.withTopicForbiddingContext (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:10565:14)
at Parser.parseFunction (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:11393:10)
at Parser.parseFunctionExpression (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:9714:17)
at Parser.parseExprAtom (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:9622:21)
at Parser.parseExprSubscripts (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:9259:23)
at Parser.parseMaybeUnary (C:\Dev\allverse3\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\@babel\parser\lib\index.js:9239:21)
Anyone know how to fix this error? Thanks. Here's package.json.
{
"name": "allverse3",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "ng run allverse3:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "9.0.2",
"@angular/common": "9.0.2",
"@angular/compiler": "9.0.2",
"@angular/core": "9.0.2",
"@angular/forms": "9.0.2",
"@angular/http": "^7.2.16",
"@angular/platform-browser": "9.0.2",
"@angular/platform-browser-dynamic": "9.0.2",
"@angular/platform-server": "9.0.2",
"@angular/router": "9.0.2",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@babel/preset-typescript": "^7.8.3",
"@nguniversal/module-map-ngfactory-loader": "8.2.6",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^4.4.1",
"component": "^1.1.0",
"core-js": "^3.6.4",
"jquery": "3.4.1",
"oidc-client": "^1.10.1",
"popper.js": "^1.16.1",
"rxjs": "^6.5.4",
"rxjs-compat": "^6.5.4",
"tslib": "^1.11.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.900.3",
"@angular/cli": "9.0.3",
"@angular/compiler-cli": "9.0.2",
"@angular/language-service": "9.0.2",
"@types/jasmine": "^3.5.6",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^13.7.4",
"codelyzer": "^5.2.1",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "~3.1.1",
"karma-jasmine-html-reporter": "^1.5.2",
"typescript": "~3.7.0"
},
"optionalDependencies": {
"node-sass": "^4.9.3",
"protractor": "~5.4.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
}
To update from one major angular version to another angular version, use the format ng update @angular/cli@^<major_version> @angular/core@^<major_version>.
During the UpdateRun NG_DISABLE_VERSION_CHECK=1 npx @angular/cli@9 update @angular/core@9 @angular/cli@9 which should bring you to version 9 of Angular.
You can run ng add @angular/localize to include required packages. Finally, run ng update @angular/core @angular/cli command to update to Angular 11. This will migrate your project to latest Angular release. After the update to Angular 11 is done your project will be using Typescript 4.
Update your Node.js to version 8 or later required by Angular 6 Update animations import from @angular/core to @angular/animations Update or install the Angular CLI to version 6 globally and locally per project Update Angular Material, if used, using ng update @angular/material
Angular material update: It gives errors in some versions of angular material when running update scripts because of the update scripts do not run smoothly in some versions. What I did is updating material after getting everything done. So when I finish with all other updates, I just ran ng update @angular/material.
Angular CLI has a new utility that allows you to automatcially analyze your project's package.json file and displays dependencies that need to be updated. Using you terminal from the root folder of your Angular 5 project run the following command: Now you need to update the core packages/dependencies to Angular 6. Simply run the following command:
First, start by installing the Angular CLI 6 locally using the following command (Make sure you are inside your project's root folder): There are many differences between Angular 4|5 and Angular 6 such as
Go to your src/main.ts
file and remove the following line
export { renderModule, renderModuleFactory } from '@angular/platform-server';
now run ng build
The issue will be fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With