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

"nx add @nx/nuxt" leads to "NX Cannot read properties of undefined (reading 'split')" #28506

Closed
1 of 4 tasks
mklueh opened this issue Oct 17, 2024 · 3 comments · Fixed by #28795
Closed
1 of 4 tasks

"nx add @nx/nuxt" leads to "NX Cannot read properties of undefined (reading 'split')" #28506

mklueh opened this issue Oct 17, 2024 · 3 comments · Fixed by #28795

Comments

@mklueh
Copy link

mklueh commented Oct 17, 2024

Current Behavior

Me again, with the beloved "NX Cannot read properties of undefined (reading 'split')" error again.

This time when trying to add the nx/nuxt plugin

$ nx add @nx/nuxt

√ Installing @nx/nuxt@20.0.1...
- Initializing @nx/nuxt...
 NX  Generating @nx/nuxt:init

(node:8640) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Convert compiler options from json failed, File '.nuxt/tsconfig.json' not found.

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

Pass --verbose to see the stacktrace.

× Initializing @nx/nuxt...

Error: Command failed: pnpm exec nx g @nx/nuxt:init --keepExistingVersions --updatePackageScripts
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at runNxSync (C:\Users\MyPC\Workspace\myproject\node_modules\nx\src\utils\child-process.js:28:34)
    at initializePlugin (C:\Users\MyPC\Workspace\myproject\node_modules\nx\src\command-line\add\add.js:106:39)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async C:\Users\MyPC\Workspace\myproject\node_modules\nx\src\command-line\add\add.js:26:9
    at async handleErrors (C:\Users\MyPC\Workspace\myproject\node_modules\nx\src\utils\handle-errors.js:9:24)
    at async Object.handler (C:\Users\MyPC\Workspace\myproject\node_modules\nx\src\command-line\add\command-object.js:25:22)

 NX   Failed to initialize @nx/nuxt. Please check the error above for more details.

I've added my project's configurations, at least those that I believe are relevant.

Expected Behavior

Fail with a clear message that helps the user / add the plugin as expected

GitHub Repo

No response

Steps to Reproduce

root tsconfig.base.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": ".",
    "rootDir": ".",
    "jsx": "preserve",
    "target": "es2015",
    "module": "esnext",
    "moduleResolution": "node",
    "noEmit": true,
    "strict": false,
    "allowJs": true,
    "sourceMap": true,
    "declaration": false,
    "skipLibCheck": true,
    "importHelpers": true,
    "noImplicitAny": true,
    "noUnusedLocals": false,
    "removeComments": true,
    "esModuleInterop": true,
    "preserveSymlinks": true,
    "noImplicitReturns": true,
    "strictNullChecks": false,
    "resolveJsonModule": true,
    "noImplicitOverride": true,
    "skipDefaultLibCheck": true,
    "strictFunctionTypes": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noUncheckedIndexedAccess": true,
    "noFallthroughCasesInSwitch": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "noPropertyAccessFromIndexSignature": false,
    "types": [
      "node"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
    "typeRoots": [
      "node_modules/@types"
    ],
    "paths": {

    }
  },
  "exclude": [
    "node_modules",
    "tmp"
  ]
}

nx.json

{
  "targetDefaults": {
    "build": {
      "dependsOn": [
        "^build"
      ],
      "inputs": [
        "production",
        "^production"
      ],
      "cache": true
    },
    "test": {
      "cache": true,
      "dependsOn": [
        "build"
      ],
      "inputs": [
        "default",
        "^default"
      ],
      "outputs": [
        "{workspaceRoot}/test/{projectRoot}"
      ]
    },
    "lint": {
      "cache": true
    },
    "e2e": {
      "inputs": [
        "default",
        "^production"
      ],
      "outputs": [
        "{workspaceRoot}/e2e/{projectRoot}"
      ],
      "cache": true
    },
    "@nx/eslint:lint": {
      "inputs": [
        "default",
        "{workspaceRoot}/.eslintrc.json",
        "{workspaceRoot}/eslint.config.ts"
      ],
      "cache": true
    },
    "@nx/vite:build": {
      "cache": true,
      "dependsOn": [
        "^build"
      ],
      "inputs": [
        "production",
        "^production"
      ]
    },
    "notify": {
      "executor": "nx:run-script",
      "options": {
        "script": "notify"
      }
    },
    "@nx/esbuild:esbuild": {
      "cache": true,
      "dependsOn": [
        "^build"
      ],
      "inputs": [
        "production",
        "^production"
      ]
    }
  },
  "workspaceLayout": {
    "appsDir": "apps",
    "libsDir": "components"
  },
  "plugins": [
    {
      "plugin": "@nx/vite/plugin",
      "options": {
        "buildTargetName": "build",
        "previewTargetName": "preview",
        "testTargetName": "test",
        "serveTargetName": "serve",
        "serveStaticTargetName": "serve-static"
      }
    },
    {
      "plugin": "@nx/eslint/plugin",
      "options": {
        "targetName": "lint"
      }
    },
    {
      "plugin": "@nx/playwright/plugin",
      "options": {
        "targetName": "e2e"
      }
    }
  ],
  "extends": "@nx/workspace/presets/core.json",
  "cli": {
    "warnings": {
      "versionMismatch": false
    },
    "packageManager": "pnpm",
    "analytics": false
  },
  "$schema": "./node_modules/nx/schemas/nx-schema.json",
  "namedInputs": {
    "default": [
      "{projectRoot}/**/*",
      "sharedGlobals"
    ],
    "sharedGlobals": [],
    "production": [
      "default",
      "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
      "!{projectRoot}/tsconfig.spec.json",
      "!{projectRoot}/eslint.config.js",
      "!{projectRoot}/eslint.config.ts",
      "!{projectRoot}/src/test-setup.[jt]s",
      "!{projectRoot}/test-setup.[jt]s"
    ]
  },
  "release": {
    "releaseTagPattern": "{projectName}-{version}",
    "projects": [

    ],
    "projectsRelationship": "independent",
    "version": {
      "git": {
        "commit": true,
        "commitArgs": "--no-verify"
      },
      "conventionalCommits": true,
      "generatorOptions": {
        "fallbackCurrentVersionResolver": "disk"
      }
    },
    "changelog": {
      "git": {
        "commit": true,
        "commitArgs": "--no-verify"
      },
      "automaticFromRef": true,
      "projectChangelogs": {
        "createRelease": false
      }
    }
  },
  "defaultBase": "master",
  "implicitDependencies": {
    "pnpm-workspace.yaml": "*",
    "pnpm-lock.yaml": "*",
    "package.json": {
      "dependencies": "*",
      "devDependencies": "*"
    },
    "nx.json": "*"
  }
}

.npmrc

# Use pnpm as the package manager
package-manager=pnpm

# Do not run build scripts of dependencies
ignore-scripts=true

# Enable shared node_modules at the root
node-linker=hoisted

# Ensure the root node_modules is used for all sub-projects
shared-workspace-lockfile=true

# Avoid duplicating dependencies in sub-projects
hoist-pattern[]=*

# Only install what's listed in the root lockfile
strict-peer-dependencies=false

Nx Report

NX Report complete - copy this into the issue template

Node : 22.9.0
OS : win32-x64
Native Target : x86_64-windows
pnpm : 9.12.1

nx : 20.0.1
@nx/js : 20.0.1
@nx/jest : 20.0.1
@nx/eslint : 20.0.1
@nx/workspace : 20.0.1
@nx/devkit : 20.0.1
@nx/esbuild : 20.0.1
@nx/eslint-plugin : 20.0.1
@nx/express : 20.0.1
@nx/node : 20.0.1
@nx/nuxt : 20.0.1
@nx/playwright : 20.0.1
@nx/vite : 20.0.1
@nx/vue : 20.0.1
@nx/web : 20.0.1
@nx/webpack : 20.0.1
typescript : 5.6.3

Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/playwright/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@xiongemi
Copy link
Collaborator

i tried to run nx add @nx/nuxt but i could not replicate this issue. do you have a link to your repo?

@xiongemi
Copy link
Collaborator

xiongemi commented Nov 1, 2024

i think it is related to #28374 and I also suspect it is related to #27736 because of the error message is also "Cannot read properties of undefined (reading 'split')".

however. i tried to run command nx add @nx/nuxt on repo https://github.com/nrwl/nx-examples on windows. and it works fine.

@xiongemi xiongemi assigned Coly010 and unassigned xiongemi Nov 4, 2024
Coly010 added a commit that referenced this issue Nov 5, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
We switched to using `loadConfigFile` from `@nx/devkit` to load Nuxt
Config files when plugins were not isolated.
However, they are now, so we can use `loadNuxtConfig` again.

The effect of using `loadConfigFile` paired with Nuxt's auto-imports
resulted in inconsistent failures.



## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Use `loadNuxtConfig` when `NX_ISOLATE_PLUGINS=true`


## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #28506
Fixes #28374
FrozenPandaz pushed a commit that referenced this issue Nov 5, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
We switched to using `loadConfigFile` from `@nx/devkit` to load Nuxt
Config files when plugins were not isolated.
However, they are now, so we can use `loadNuxtConfig` again.

The effect of using `loadConfigFile` paired with Nuxt's auto-imports
resulted in inconsistent failures.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Use `loadNuxtConfig` when `NX_ISOLATE_PLUGINS=true`

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #28506
Fixes #28374

(cherry picked from commit be7bfa4)
FrozenPandaz pushed a commit that referenced this issue Nov 5, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
We switched to using `loadConfigFile` from `@nx/devkit` to load Nuxt
Config files when plugins were not isolated.
However, they are now, so we can use `loadNuxtConfig` again.

The effect of using `loadConfigFile` paired with Nuxt's auto-imports
resulted in inconsistent failures.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Use `loadNuxtConfig` when `NX_ISOLATE_PLUGINS=true`

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #28506
Fixes #28374

(cherry picked from commit be7bfa4)
Copy link

github-actions bot commented Dec 9, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants