Workspace file utils throws: Cannot read property 'length' of undefined
See original GitHub issueCurrent Behavior
When running nx run mytarget:build --verbose it fails with
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at Object.filesChanged (/.../node_modules/@nrwl/node/node_modules/@nrwl/workspace/src/core/file-utils.js:255:24)
at Object.createProjectGraph (/.../node_modules/@nrwl/node/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js:21:32)
at buildExecutor (/.../node_modules/@nrwl/node/src/executors/build/build.impl.js:28:39)
at /.../node_modules/@nrwl/tao/src/commands/run.js:134:23
at Generator.next (<anonymous>)
at /.../node_modules/tslib/tslib.js:117:75
at new Promise (<anonymous>)
Expected Behavior
It builds the target
Steps to Reproduce
Hard to tell issue is located inside
node_modules/@nrwl/node/node_modules/@nrwl/workspace/src/core/file-utils.js
function filesChanged(a, b) {
+ console.log(a,b)
+ if (a.length !== b?.length)
- if (a.length !== b.length)
return true;
The optional chaining on b does the trick and the console.log prints the following output:
[
{
file: 'package.json',
hash: '1d085cde9f328c6fbe905dff7068ca8b70efdba0',
ext: '.json'
},
{
file: 'workspace.json',
hash: '62266cc6a1d39f52da09833b25d8c6d545e46b19',
ext: '.json'
},
{
file: 'nx.json',
hash: 'dcad049f2fa8f67840dc27514732a8992aae73aa',
ext: '.json'
},
{
file: 'tsconfig.base.json',
hash: '11253ac5c2b7bc7ccc8003036c9379134582575c',
ext: '.json'
}
] undefined
Failure Logs
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at Object.filesChanged (/.../node_modules/@nrwl/node/node_modules/@nrwl/workspace/src/core/file-utils.js:255:24)
at Object.createProjectGraph (/.../node_modules/@nrwl/node/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js:21:32)
at buildExecutor (/.../node_modules/@nrwl/node/src/executors/build/build.impl.js:28:39)
at /.../node_modules/@nrwl/tao/src/commands/run.js:134:23
at Generator.next (<anonymous>)
at /.../node_modules/tslib/tslib.js:117:75
at new Promise (<anonymous>)
Environment
nx report
> NX Report complete - copy this into the issue template
Node : 16.7.0
OS : darwin x64
npm : 7.20.3
nx : 12.10.0
@nrwl/angular : Not Found
@nrwl/cli : 12.10.0
@nrwl/cypress : 12.10.0
@nrwl/devkit : 12.10.0
@nrwl/eslint-plugin-nx : 12.10.0
@nrwl/express : Not Found
@nrwl/jest : 12.10.0
@nrwl/linter : 12.10.0
@nrwl/nest : 12.5.9
@nrwl/next : Not Found
@nrwl/node : 12.5.9
@nrwl/nx-cloud : 12.3.13
@nrwl/react : 12.10.0
@nrwl/schematics : Not Found
@nrwl/tao : 12.10.0
@nrwl/web : 12.10.0
@nrwl/workspace : 12.10.0
@nrwl/storybook : 12.10.0
@nrwl/gatsby : Not Found
typescript : 4.4.4
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Cannot Read Property Length of Undefined in JavaScript
The JavaScript TypeError: Cannot read property 'length' of undefined occurs when the length property is read on an undefined variable.
Read more >Typescript throws: Cannot read property 'length' of undefined
Good thing to check. I refactored some components manually and forgot to make updates inside the component.ts file to match. The error isn't ......
Read more >Refreshing sidebar: Cannot read property 'length' of undefined
Summary Open "ISSUES AND MERGE REQUESTS" Clicking on "GitLab: Refresh sidebar" causes error messages: Failed to parse...
Read more >Cannot read properties of undefined (reading 'length') - TrackJS
This message indicates that our code expects to have an object with a length property, but that object was not present.
Read more >TypeError: Cannot read property 'length' of undefined
TypeError : Cannot read property 'length' of undefined. What's wrong with my code? Thanks. *. var carlos = [9.6,10.6,11.2,10.3,11.5]; var ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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

rm -rf ./node_modules/.cache/nx
Also ran into this issue, here is the report:
I had to kill the
node_modulesand re-install the dependencies to get rid of this.