Skip to content
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

ng build --prod: Cannot read property '_walk' of null #12414

Closed
rolphes opened this issue Sep 30, 2018 · 22 comments
Closed

ng build --prod: Cannot read property '_walk' of null #12414

rolphes opened this issue Sep 30, 2018 · 22 comments

Comments

@rolphes
Copy link

rolphes commented Sep 30, 2018

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Node: v8.11.1
NPM: 6.4.1

Angular CLI: 6.2.3
Node: 8.11.1
OS: win32 x64
Angular: 6.1.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.8.3
@angular-devkit/build-angular 0.8.3
@angular-devkit/build-optimizer 0.8.3
@angular-devkit/build-webpack 0.8.3
@angular-devkit/core 0.8.3
@angular-devkit/schematics 0.8.3
@angular/cli 6.2.3
@ngtools/webpack 6.2.3
@schematics/angular 0.8.3
@schematics/update 0.8.3
rxjs 6.3.3
typescript 2.7.2
webpack 4.20.2

Windows 10

Repro steps

execute "ng build --prod" -> sorry, I can't provide the repo.

This bug suddenly popped up on our build server two days ago. Before that, this problem never occurred. After cleaning node_moduls and npm install I can reproduce the error on my machine too.

The log given by the failure

`Date: 2018-09-28T18:28:46.879Z
Hash: 2fa0d73885177ad3220b
Time: 109957ms
chunk {0} runtime.ec2944dd8b20ec099bf3.js (runtime) 1.44 kB [entry] [rendered]
chunk {1} main.85d86102e68c1db8c7c4.js (main) 8.08 MB [initial] [rendered]
chunk {2} polyfills.c2c353082061f41763b0.js (polyfills) 98.3 kB [initial] [rendered]
chunk {3} styles.c5267d72f9cea9ab11f3.css (styles) 150 kB [initial] [rendered]

ERROR in main.85d86102e68c1db8c7c4.js from UglifyJs
TypeError: Cannot read property '_walk' of null
at AST_Dot.eval (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :1112:29)
at TreeWalker._visit (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :1513:21)
at AST_Dot._walk (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :1111:24)
at AST_VarDef.eval (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :1058:40)
at TreeWalker._visit (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :1513:21)
at AST_VarDef._walk (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :1056:24)
at AST_Var.eval (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :966:32)
at TreeWalker._visit (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :1513:21)
at AST_Var._walk (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :963:24)
at walk_body (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :513:17)
at AST_Function.eval (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :739:13)
at TreeWalker._visit (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :1513:21)
at AST_Function._walk (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :733:24)
at AST_Function.walk (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :467:21)
at get_lvalues (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :8804:34)
at collapse (eval at (E:\jenkins\ProjectX\workspace\node_modules\uglifyjs-webpack-plugin\node_modules\uglify-es\tools\node.js:21:1), :8565:35)
Build step 'Execute Windows batch command' marked build as failure
[TASKS] Skipping publisher since build result is FAILURE
Skipped archiving because build is not successful`

Desired functionality

Build optimization with uglifyjs works as before

Mention any other details that might be useful

Similar errors are filed for ember-cli: ember-cli/ember-cli#8075

@rolphes
Copy link
Author

rolphes commented Oct 1, 2018

The error comes from the uglify-js package. With uglifyjs 3.3.4 it works as expected. The error "Cannot read property '_walk' of null" occours starting from version 3.3.5.

@tomjwilliamson
Copy link

+1 same issue

@seanzhu0925
Copy link

were you guys able to resolve the issue? what was the fix?

@seanzhu0925
Copy link

uglify-js is part of cli transitive dependency, when you do npm install, it will grab uglify-js 3.39 in my case. how can i override the dependency in package.json? or downgrade the version?

@clydin
Copy link
Member

clydin commented Oct 5, 2018

if using yarn, using the resolutions field within package.json would allow you to do that.

Also, CLI 7.0 (currently in release candidate stage) uses a new variant of uglify-es named terser which should alleviate the issues being faced here.

@seanzhu0925
Copy link

fixed the issue by changing the ES lib version in tsconfig.json file. it was es2017, changed to es2015 { "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2015", "dom" ] } }

@DingWeizhe
Copy link

DingWeizhe commented Oct 9, 2018

If your project have a dependency tether, Try downgrade the version to 1.4.3.

shipshapecode/tether#291

@Ravell7
Copy link

Ravell7 commented Oct 9, 2018

Thank you @DingWeizhe ! I'm on that bug since yesterday !

@filipesilva
Copy link
Contributor

Heya just wanted to mention we are aware of this issue, and waiting for a resolution in terser/terser#120. Then we'll update the version we use of terser (the uglifier in our pipeline).

@tomjwilliamson
Copy link

tomjwilliamson commented Oct 9, 2018

I fixed the issue the same as @DingWeizhe - downgraded tether. Just went through all my dependencies and checked which had the latest release, and tried the last version

@seanzhu0925
Copy link

also did npm update, @angular/compiler-cli version was updated, and it fixed the issue permanently.

@inpicksys
Copy link

inpicksys commented Oct 28, 2018

@seanzhu0925 I updating everything, I can't fix this issue with @angular/compiler-cli.
Could someone describe in details how to avoid this issue during ng build --prod? (not locally but on CI server)?
This is blocking issue for me. I can't deploy application.

@filipesilva
Copy link
Contributor

This issue is now fixed in terser@3.10.7. Angular CLI does not depend on terser directly, but you can force it to update by following these steps:

  • check the current installed version of terser: npm ls terser
  • install and uninstall terser to update your lockfile npm install terser@3.10.7 npm uninstall terser
  • you should now see the latest terser in npm ls terser

@paustint
Copy link

paustint commented Nov 2, 2018

@seanzhu0925 I updating everything, I can't fix this issue with @angular/compiler-cli.
Could someone describe in details how to avoid this issue during ng build --prod? (not locally but on CI server)?
This is blocking issue for me. I can't deploy application.

@inpicksys - my issue was that @angular-devkit/build-angular was not updated with ng update and I missed this, so I was still not using terser.

@Sijoma
Copy link

Sijoma commented Nov 6, 2018

We are using Angular4 and this issue also effects our production build. How do I install terser so that Angular uses it instead of uglifyJS?

The weird thing is that we have not updated our dependencies.

@filipesilva
Copy link
Contributor

@Sijoma you'll need to be using at least Angular CLI 7 for the build system to be using Terser.

@Sijoma
Copy link

Sijoma commented Nov 6, 2018

@Sijoma you'll need to be using at least Angular CLI 7 for the build system to be using Terser.

Okay, we currently have stick with Angular 4, do you have any suggestions on how to fix the issue there?

@filipesilva
Copy link
Contributor

You can try using Angular 4 with Angular CLI 7. It's not something we test for but might work. Other than that.. maybe we you can using Yarn to always resolve the uglify-js package to a version that doesn't exhibit this bug.

Hard to say at this point, it looks like the packages you are using are somewhat outdated. I really do encourage you to use a lockfile though, either through npm or yarn. Without it, your dependencies can change even if you don't update anything.

@Sijoma
Copy link

Sijoma commented Nov 6, 2018

Thanks filipesilva, I found an older lockfile and managed to use that. Just FYI Building with the CLI Version 7 did not work.

I immediately removed the lockfile from the gitignore and committed it 😅.

@JohnGalt1717
Copy link

This is back.

@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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests