nx
nx copied to clipboard
nx init fails with error: Error: ENOENT: no such file or directory, lstat
Current Behavior
When trying to migrate existing react app created with cra and running a command npx nx init as described in the documentation from CRA I'm sumbling upon a weird issue on the later stage of migration process:
Error: ENOENT: no such file or directory, lstat
the process fails and leave the temp-workspace
folder as an artefact
Expected Behavior
nx init command works as expected and react app is migrated to nx successully
Github Repo
No response
Steps to Reproduce
- checkout repo created with CRA
- run command
npx nx init --vite=false
Nx Report
> NX The current directory isn't part of an Nx workspace.
To create a workspace run:
npx create-nx-workspace@latest <workspace name>
To add Nx to existing workspace run with a workspace-specific nx.json:
npx add-nx-to-monorepo@latest
To add the default nx.json file run:
nx init
> NX For more information please visit https://nx.dev/
Failure Logs
> NX 👋 Welcome to Nx!
> NX 🧹 Clearing unused files
Error: ENOENT: no such file or directory, lstat 'temp-workspace/apps/web_opxp_onboarding/project.json'
at Object.lstatSync (node:fs:1561:3)
at Object.lstatSync (/home/podgaev/.npm/_npx/8331ccaaf37e1499/node_modules/graceful-fs/polyfills.js:318:34)
at statFunc (/home/podgaev/.npm/_npx/8331ccaaf37e1499/node_modules/fs-extra/lib/util/stat.js:24:20)
at getStatsSync (/home/podgaev/.npm/_npx/8331ccaaf37e1499/node_modules/fs-extra/lib/util/stat.js:25:19)
at Object.checkPathsSync (/home/podgaev/.npm/_npx/8331ccaaf37e1499/node_modules/fs-extra/lib/util/stat.js:67:33)
at copySync (/home/podgaev/.npm/_npx/8331ccaaf37e1499/node_modules/fs-extra/lib/copy/copy-sync.js:27:38)
at createTempWorkspace (/home/podgaev/.npm/_npx/8331ccaaf37e1499/node_modules/cra-to-nx/src/lib/cra-to-nx.js:127:29) at /home/podgaev/.npm/_npx/8331ccaaf37e1499/node_modules/cra-to-nx/src/lib/cra-to-nx.js:67:9
at Generator.next (<anonymous>)
at /home/podgaev/.npm/_npx/8331ccaaf37e1499/node_modules/tslib/tslib.js:118:75 {
errno: -2,
syscall: 'lstat',
code: 'ENOENT',
path: 'temp-workspace/apps/web_opxp_onboarding/project.json'
}
nx init
Adds nx.json file and installs nx if not installed already
Options:
--help Show help [boolean] --version Show version number [boolean]
Error: Command failed: npx --yes cra-to-nx@latest init --vite=false
at checkExecSyncError (node:child_process:861:11)
at execSync (node:child_process:932:15)
at Object.<anonymous> (/home/podgaev/.npm/_npx/973fb08ee51bb939/node_modules/nx/src/command-line/init.js:26:46)
at Generator.next (<anonymous>)
at /home/podgaev/.npm/_npx/973fb08ee51bb939/node_modules/tslib/tslib.js:118:75
at new Promise (<anonymous>)
at Object.__awaiter (/home/podgaev/.npm/_npx/973fb08ee51bb939/node_modules/tslib/tslib.js:114:16)
at Object.initHandler (/home/podgaev/.npm/_npx/973fb08ee51bb939/node_modules/nx/src/command-line/init.js:11:20)
at /home/podgaev/.npm/_npx/973fb08ee51bb939/node_modules/nx/src/command-line/nx-commands.js:207:71 {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 5945,
stdout: null,
stderr: null
}
npm notice
npm notice New major version of npm available! 8.19.3 -> 9.2.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.2.0
npm notice Run npm install -g [email protected] to update!
npm notice
Additional Information
I'm using Node v.16.19.0, yarn v.1.22.19, npx v.8.19.3
I'm seeing this issue as well with a Create React App
experiencing same issue
Hi there @alexiusp @cbroomemktw @yasin459 ! Thanks for filing this issue!
I cannot reproduce this issue any more. Here are my logs:
-
npx create-react-app my-app
: https://app.warp.dev/block/GAOlgXLCtK31GUGgR6EylI -
cd my-app/
-
npx nx init --vite=false
: https://app.warp.dev/block/SwKltQC03HhfJM6hJCAdwK
Can you please retry with latest version and let me know if it persists?
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
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.