nxtend-team / nxtend

MIT License
189 stars 42 forks source link

Error: Cannot read properties of undefined (reading 'length') when running any capacitor command #633

Open vrxj81 opened 2 years ago

vrxj81 commented 2 years ago

Whenever running any Capacitor related command, I get this output:

nx run ggs-mobile:copy:ios

> nx run ggs-mobile:copy:ios

Cannot read properties of undefined (reading 'length')

 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target copy for project ggs-mobile (328ms)

         With additional flags:

    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

   See Nx Cloud run details at https://nx.app/runs/XXXXXXXXXX

No idea how to debug this

dolphinigle commented 2 years ago

Seconding this, started getting this error after updating to nx 14:

    "firebase": {
      "executor": "@nxtend/firebase:firebase",
    },
> nx run solui:firebase --cmd="deploy -P staging --token=*******************************************************************************************************"

Cannot read properties of undefined (reading 'length')
"@angular/core": "14.0.1",
"@nrwl/workspace": "14.3.1",
"@nxtend/firebase": "12.1.0",
"firebase": "9.8.3",
vrxj81 commented 2 years ago

Seconding this, started getting this error after updating to nx 14:

    "firebase": {
      "executor": "@nxtend/firebase:firebase",
    },
> nx run solui:firebase --cmd="deploy -P staging --token=*******************************************************************************************************"

Cannot read properties of undefined (reading 'length')

Thanks for confirming my suspicion. It worked with NX 14.1, but not with 14.3.

Is there a transparency on the status of supporting NX 14?

dolphinigle commented 2 years ago

https://github.com/nrwl/nx/commit/5c49345c34975fcb6c32c47ec233a28d0154a17f

This commit seems to be the culprit. They are adding __unparsed__ as a required parameter to run-commands.

See dummy pull request below

dolphinigle commented 2 years ago

For now, reverting to nx 14.2.x solves this issue. I've also opened an issue in nx: https://github.com/nrwl/nx/issues/10750

dolphinigle commented 2 years ago

Nx has fixed this

VictorienTardif commented 2 years ago

Nx has fixed this

Nope :( I upgraded Nx to 14.3.5, the __unparsed__ bug may be fixed but not the Cannot read properties of undefined (reading 'length') one.

I don't think it's related.

borgoat commented 2 years ago

Apparently this was fixed in PR https://github.com/nrwl/nx/pull/10753 and then reverted in commit https://github.com/nrwl/nx/commit/d68b9bbc9094829adcc9431bdcf0c5e08980a83a

muuvmuuv commented 2 years ago

Is anyone working on a fix? Tried every version since 14 and none worked.

muuvmuuv commented 2 years ago

You can use this patch here. Git, pnpm@7.4 (below) and yarn supports patching node modules.

{
  "pnpm": {
    "patchedDependencies": {
      "nx@14.3.6": "patches/nx@14.3.6.patch"
    }
  }
}
diff --git a/src/executors/run-commands/run-commands.impl.js b/src/executors/run-commands/run-commands.impl.js
index d2c45a4405755b63e541b060f0e7631781f33b9c..052e0a4c172454d8c3cfae567739baa5fc1e3be6 100644
--- a/src/executors/run-commands/run-commands.impl.js
+++ b/src/executors/run-commands/run-commands.impl.js
@@ -190,7 +190,7 @@ function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
         return command.replace(regex, (_, group) => opts.parsedArgs[group]);
     }
     else if (forwardAllArgs) {
-        return `${command}${opts.__unparsed__.length > 0 ? ' ' + opts.__unparsed__.join(' ') : ''}`;
+        return `${command}${opts.__unparsed__?.length > 0 ? ' ' + opts.__unparsed__.join(' ') : ''}`;
     }
     else {
         return command;
devinshoemaker commented 2 years ago

These plugins are moving over to the Nxext repo, and an Nx 14 version has been released. There are some migration guides on their docs site, here's a link to the Ionic Angular guide: https://nxext.dev/docs/ionic-angular/migrating-from-nxtend.html

cangomescisco commented 2 years ago

@devinshoemaker Thanks! :)

f1ght4fun commented 2 years ago

It is still present in the NX15 version ... Is there really a chance to fix this as builds are failing with this issue since Nx14 version ?

NX Cannot read property 'length' of undefined

TypeError: Cannot read property 'length' of undefined at interpolateArgsIntoCommand (/Users/f1ght4fun/node_modules/nx/src/executors/run-commands/run-commands.impl.js:193:47) at /Users/f1ght4fun/node_modules/nx/src/executors/run-commands/run-commands.impl.js:106:21 at Array.forEach () at normalizeOptions (/Users/f1ght4fun/node_modules/nx/src/executors/run-commands/run-commands.impl.js:104:22) at /Users/f1ght4fun/node_modules/nx/src/executors/run-commands/run-commands.impl.js:41:28 at Generator.next () at fulfilled (/Users/f1ght4fun/node_modules/tslib/tslib.js:115:62) at processTicksAndRejections (internal/process/task_queues.js:95:5)