NX Cannot read properties of undefined (reading 'length')

Viewed 28

I'm using nx for a project and all I have is a svelte kit project, untouched, generated using this command:

nx g @nxext/sveltekit:app dashboard

when running nx serve dashboard I get this error

 >  NX   Cannot read properties of undefined (reading 'length')


TypeError: Cannot read properties of undefined (reading 'length')
    at interpolateArgsIntoCommand (C:\Users\USER\Documents\Assassin\node_modules\nx\src\executors\run-commands\run-commands.impl.js:193:47)
    at C:\Users\USER\Documents\Assassin\node_modules\nx\src\executors\run-commands\run-commands.impl.js:106:21
    at Array.forEach (<anonymous>)
    at normalizeOptions (C:\Users\USER\Documents\Assassin\node_modules\nx\src\executors\run-commands\run-commands.impl.js:104:22)
    at C:\Users\USER\Documents\Assassin\node_modules\nx\src\executors\run-commands\run-commands.impl.js:41:28 
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\USER\Documents\Assassin\node_modules\tslib\tslib.js:115:62)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

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

 >  NX   Running target "dashboard:serve" failed

   Failed tasks:

   - dashboard:serve

   Hint: run the command with --verbose for more details.

also the "Hint" is a little weird since I already have the --verbose flag.

1 Answers

I'm pretty sure this is just the @nxext nx plugin being outdated. Svelte Kit just entered release candidate, but until now its API was changing a lot.

You can do the following in vanilla nx:

apps/myapp/project.json

{
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "name": "myapp",
  "sourceRoot": "packages/myapp/src",
  "targets": {
    "build": {
      "executor": "nx:run-script",
      "outputs": [
        "packages/myapp/.svelte-kit",
        "packages/myapp/build"
      ],
      "options": {
        "script": "build"
      }
    },
    "dev": {
      "executor": "nx:run-script",
      "outputs": [
        "packages/myapp/.svelte-kit"
      ],
      "options": {
        "script": "dev"
      }
    }
}

I guess you know, but not having corresponding NX targets will just run the npm script with the same name.

The only reason I like to use NX targets (or custom workspace plugins) is that you can specify the outputs that are used by NX cache .

Related