nx: "contains invalid WIN32 path characters" when execute the command npx create-nx-workspace

Current Behavior

When try create a new project with Angular + SASS + ESLint + NxCloud/Not NxCloud with npx create-nx-workspace

Expected Behavior

Create a new project sucessfully

Steps to Reproduce

npm install -g @nrwl/cli@latest npm i -g @nrwl/workspace@latest npm install -g @nrwl/angular@latest npm install -g @angular/cli@latest npm install -g nx@latest npx create-nx-workspace@latest E:>npx create-nx-workspace@latest ? Workspace name (e.g., org name) empresa ? What to create in the new workspace angular [a workspace with a single Angular application] ? Application name tienda ? Default stylesheet format SASS(.scss) [ http://sass-lang.com ] ? Default linter ESLint [ Modern linting tool ] ? Use Nx Cloud? (It’s free and doesn’t require registration.) No

Failure Logs

E:>npx create-nx-workspace@latest ? Workspace name (e.g., org name) empresa ? What to create in the new workspace angular [a workspace with a single Angular application] ? Application name tienda ? Default stylesheet format SASS(.scss) [ http://sass-lang.com ] ? Default linter ESLint [ Modern linting tool ] ? Use Nx Cloud? (It’s free and doesn’t require registration.) No Creating a sandbox with Nx… new empresa --no-interactive --preset=angular --appName=tienda --style=scss --linter=eslint --no-nxCloud --collection=@nrwl/workspace CREATE empresa/nx.json CREATE empresa/package.json CREATE empresa/README.md CREATE empresa/tools/generators/.gitkeep CREATE empresa/tools/tsconfig.tools.json CREATE empresa/tsconfig.base.json CREATE empresa/.editorconfig CREATE empresa/.gitignore CREATE empresa/.prettierignore CREATE empresa/.vscode/extensions.json CREATE empresa/angular.json CREATE empresa/.prettierrc CREATE empresa/decorate-angular-cli.js CREATE empresa/apps/.gitkeep CREATE empresa/libs/.gitkeep \E:\empresa contains invalid WIN32 path characters. npm ERR! code 1 npm ERR! path C:\Users\ALVARO~1\AppData\Local\Temp\tmp-123440MhKDe8Wa3am npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c tao new empresa --no-interactive --preset=angular --appName=tienda --style=scss --linter=eslint --no-nxCloud --collection=@nrwl/workspace/collection.json --cli=angular --nxWorkspaceRoot=\E😕\

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\alvaroheavy\AppData\Local\npm-cache_logs\2021-02-03T13_01_18_000Z-debug.log (node:12344) UnhandledPromiseRejectionWarning: Error: Command failed: npx tao new empresa --no-interactive --preset=angular --appName=tienda --style=scss --linter=eslint --no-nxCloud --collection=@nrwl/workspace/collection.json --cli=angular --nxWorkspaceRoot="E:/" at checkExecSyncError (child_process.js:630:11) at Object.execSync (child_process.js:666:15) at createApp (C:\Users\alvaroheavy\AppData\Local\npm-cache_npx\505743838affa773\node_modules\create-nx-workspace\bin\create-nx-workspace.js:380:21) at C:\Users\alvaroheavy\AppData\Local\npm-cache_npx\505743838affa773\node_modules\create-nx-workspace\bin\create-nx-workspace.js:97:29 at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:12344) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:12344) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Environment

Global packages npm: @angular-devkit/core 11.1.2 @angular/cli 11.1.2 @ionic/cli 6.12.4 @nrwl/angular 11.2.9 @nrwl/cli 11.2.9 @nrwl/workspace 11.2.9 capacitor-resources 2.0.5 cordova-res 0.15.3 cordova 9.0.0 native-run 1.3.0 node-dev 6.2.0 npm-gui 2.1.0 npm-server 0.0.1 npm 7.5.2 nx 11.2.9

Operating System: Windows Enterprise 10 x64 Processors: Intel i7 4770k Memory: 16 GiB of RAM

Notes

I tried different drives and different routes.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 22 (1 by maintainers)

Commits related to this issue

Most upvoted comments

With v11.2.12 yes, this works in any path.

Thank you very much to all.

got a new error when i move project folder to C:

EINVAL: invalid argument, mkdir 'C:\C:\project\testorg'

use #4734

everything is ok…

thx, bro. @ruekart

we just released v11.2.12 which should contain the fix for this: 57c6bac. Can you please try again and let us know if this works now as expected?

I’m sorry, but this doesn’t work …

\D:\prog\maxl contains invalid WIN32 path characters.

EDIT : Even on C: it won’t work …

I think I’m gonna have to check for something else to build my project for now, because I kept pushing it back.

Here’s the log on C: :

EINVAL: invalid argument, mkdir 'C:\C:\temp\maxlgame'
npm ERR! code 1
npm ERR! path C:\Users\maxle\AppData\Local\Temp\tmp-6032StG41Oeh5YXq
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c tao new maxlgame --no-interactive --preset=react-express --appName=game --style=styled-components --linter=eslint --no-nxCloud --collection=@nrwl/workspace/collection.json --cli=nx --nxWorkspaceRoot=\C:/temp\

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\maxle\AppData\Local\npm-cache\_logs\2021-02-12T19_14_14_602Z-debug.log
(node:6032) UnhandledPromiseRejectionWarning: Error: Command failed: npx tao new maxlgame --no-interactive --preset=react-express --appName=game --style=styled-components --linter=eslint --no-nxCloud --collection=@nrwl/workspace/collection.json --cli=nx --nxWorkspaceRoot=\"C:/temp\"
    at checkExecSyncError (child_process.js:616:11)
    at Object.execSync (child_process.js:652:15)
    at createApp (C:\Users\maxle\AppData\Local\npm-cache\_npx\d2207cf76adb22dc\node_modules\create-nx-workspace\bin\create-nx-workspace.js:380:21)
    at C:\Users\maxle\AppData\Local\npm-cache\_npx\d2207cf76adb22dc\node_modules\create-nx-workspace\bin\create-nx-workspace.js:97:29
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6032) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:6032) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Here’s the complete log on D: :

\D:\prog\maxlgame contains invalid WIN32 path characters.
npm ERR! code 1
npm ERR! path C:\Users\maxle\AppData\Local\Temp\tmp-4176qYOEs42UMxUA
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c tao new maxlgame --no-interactive --preset=react-express --appName=game --style=styled-components --linter=eslint --no-nxCloud --collection=@nrwl/workspace/collection.json --cli=nx --nxWorkspaceRoot=\D:/prog\

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\maxle\AppData\Local\npm-cache\_logs\2021-02-12T19_11_24_011Z-debug.log
(node:4176) UnhandledPromiseRejectionWarning: Error: Command failed: npx tao new maxlgame --no-interactive --preset=react-express --appName=game --style=styled-components --linter=eslint --no-nxCloud --collection=@nrwl/workspace/collection.json --cli=nx --nxWorkspaceRoot=\"D:/prog\"
    at checkExecSyncError (child_process.js:616:11)
    at Object.execSync (child_process.js:652:15)
    at createApp (C:\Users\maxle\AppData\Local\npm-cache\_npx\505743838affa773\node_modules\create-nx-workspace\bin\create-nx-workspace.js:380:21)
    at C:\Users\maxle\AppData\Local\npm-cache\_npx\505743838affa773\node_modules\create-nx-workspace\bin\create-nx-workspace.js:97:29
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4176) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4176) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

we just released v11.2.12 which should contain the fix for this: 57c6bacfb4c33aba5abe13a742791b5b315da528. Can you please try again and let us know if this works now as expected?

Another option is to use e.g. Ubuntu with the Windows Subsystem for Linux:

  1. Enable WSL and install WSL’s e.g. Ubuntu (v20 LTS worked for me)
  2. Use nvm.sh (node version manager) to install node (v14.16.0 LTS) with npm (6.14.11)
  3. Make sure you have set git’s identity properties user.email and user.name (just avoids a later git error during setup of nx workspace)
  4. npm i -g create-nx-workspace@11.4.0
  5. cd /mnt/c/where/ever/your/workspace/is
  6. create-nx-workspace foobar

The created nx workspace can now be found in C:\where\ever\your\workspace\is\foobar

How is this bug not a Critical? Can’t create workspace in G:/PROJECTS/name/ or G:/ C:/ or wherever. Windows it is.

EDIT: Can I just copy rendered empty template from somewhere?

Seems like the issue was introduced by the change 9abdb78a4ab44c8bee1ca8fb09c763c011dc1db3 packages/create-nx-workspace/bin/create-nx-workspace.ts at line 422. I removed the ‘win32’ condition locally and successfully bypass the issue.

node v14.15.4 npm 6.14.9

I don’t know if is all npm 7 related. When I tried to create a workspace in my D unit in D:/project I’ve got this error:

CREATE workspace/nx.json
CREATE workspace/package.json
CREATE workspace/README.md
CREATE workspace/tools/generators/.gitkeep
CREATE workspace/tools/tsconfig.tools.json
CREATE workspace/tsconfig.base.json
CREATE workspace/.editorconfig
CREATE workspace/.gitignore
CREATE workspace/.prettierignore
CREATE workspace/.vscode/extensions.json
CREATE workspace/workspace.json
CREATE workspace/.prettierrc
CREATE workspace/apps/.gitkeep
CREATE workspace/libs/.gitkeep
spawnSync C:\WINDOWS\system32\cmd.exe ENOENT
(node:16396) UnhandledPromiseRejectionWarning: Error: Command failed: npx tao new workspace --no-interactive --preset=empty --appName= --linter=eslint --no-nxCloud --collection=@nrwl/workspace/collection.json --cli=nx --nxWorkspaceRoot=\"D:/project\"
    at checkExecSyncError (child_process.js:616:11)
    at Object.execSync (child_process.js:652:15)
    at createApp (C:\Users\ruekart\AppData\Roaming\npm-cache\_npx\16396\node_modules\create-nx-workspace\bin\create-nx-workspace.js:380:21)
    at C:\Users\ruekart\AppData\Roaming\npm-cache\_npx\16396\node_modules\create-nx-workspace\bin\create-nx-workspace.js:97:29
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:16396) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:16396) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

But when I tried in my C unit in C:\project the workspace is created correctly with this output:

CREATE workspace/nx.json
CREATE workspace/package.json
CREATE workspace/README.md
CREATE workspace/tools/generators/.gitkeep
CREATE workspace/tools/tsconfig.tools.json
CREATE workspace/tsconfig.base.json
CREATE workspace/.editorconfig
CREATE workspace/.gitignore
CREATE workspace/.prettierignore
CREATE workspace/.vscode/extensions.json
CREATE workspace/workspace.json
CREATE workspace/.prettierrc
CREATE workspace/apps/.gitkeep
CREATE workspace/libs/.gitkeep
npm notice created a lockfile as package-lock.json. You should commit this file.
added 249 packages from 235 contributors and audited 251 packages in 9.012s

Then I moved my workspace manually to my D unit and the nx cli also worked perfectly.

Very good call @vltansky , that was indeed the issue! I downgraded node to v10.16.3 and npm to 6.14.11 then it worked as usual.

While using node v10.16.3 with npm@7, the issue was still present. It’s only when I went back to npm@6 that it worked.

Probably npm 7 is related. This error didn’t happen to me on another pc with npm 6 and everybody who wrote here has npm 7