question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nx g @nrwl/nest:application changes `/` in project paths to `\\` in workspace.json

See original GitHub issue

Current Behavior

When I generate a new NestJS application in my Nx workspace, \\ is now used where a / was in the workspace.json file for project paths. However this only applies to existing projects, the newly generated project does use /.

Expected Behavior

The application generator does not change or mix / and \\ usage.

Steps to Reproduce

  1. create-nx-workspace --name test-project --preset empty --nx-cloud false
  2. cd test-project
  3. cat workspace.json
{
  "version": 2,
  "projects": {},
  "cli": {
    "defaultCollection": "@nrwl/workspace"
  }
}
  1. npm i -D @nrwl/nest
  2. nx g @nrwl/nest:application api --standaloneConfig

Above command prints out an error but does succeed, see issue #6249, possibly relevant. However this behaviour still occurs even if I omit --standaloneConfig from the second command (step 7) and the error does not happen then.

Failed to format: /angular.json
Error: 'project.json' files are incompatible with version 1 workspace schemas.
    at C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\tao\src\shared\workspace.js:208:19
    at Array.forEach (<anonymous>)
    at toOldFormatOrNull (C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\tao\src\shared\workspace.js:206:37)
    at Object.reformattedWorkspaceJsonOrNull (C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\tao\src\shared\workspace.js:167:53)
    at updateWorkspaceJsonToMatchFormatVersion (C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\devkit\src\generators\format-files.js:59:41)
    at Object.<anonymous> (C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\devkit\src\generators\format-files.js:21:9)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\Jeroen\Projects\test-project\node_modules\tslib\tslib.js:114:62)
Failed to format: /angular.json
Error: 'project.json' files are incompatible with version 1 workspace schemas.
    at C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\tao\src\shared\workspace.js:208:19
    at Array.forEach (<anonymous>)
    at toOldFormatOrNull (C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\tao\src\shared\workspace.js:206:37)
    at Object.reformattedWorkspaceJsonOrNull (C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\tao\src\shared\workspace.js:167:53)
    at updateWorkspaceJsonToMatchFormatVersion (C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\devkit\src\generators\format-files.js:59:41)
    at Object.<anonymous> (C:\Users\Jeroen\Projects\test-project\node_modules\@nrwl\devkit\src\generators\format-files.js:21:9)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\Jeroen\Projects\test-project\node_modules\tslib\tslib.js:114:62)
  1. cat workspace.json
{
  "version": 2,
  "projects": {
    "api": "apps/api"
  },
  "cli": {
    "defaultCollection": "@nrwl/nest"
  },
  "defaultProject": "api"
}
  1. nx g @nrwl/nest:application api2 --standaloneConfig
  2. cat workspace.json
{
  "version": 2,
  "projects": {
    "api": "apps\\api",
    "api2": "apps/api2"
  },
  "cli": {
    "defaultCollection": "@nrwl/nest"
  },
  "defaultProject": "api"
}

Failure Logs

None.

Environment

  Node : 14.16.0
  OS   : win32 x64
  npm  : 6.14.13

  nx : Not Found
  @nrwl/angular : Not Found
  @nrwl/cli : 12.5.8
  @nrwl/cypress : Not Found
  @nrwl/devkit : 12.5.8
  @nrwl/eslint-plugin-nx : 12.5.8
  @nrwl/express : Not Found
  @nrwl/jest : 12.5.8
  @nrwl/linter : 12.5.8
  @nrwl/nest : 12.5.8
  @nrwl/next : Not Found
  @nrwl/node : 12.5.8
  @nrwl/nx-cloud : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 12.5.8
  @nrwl/web : Not Found
  @nrwl/workspace : 12.5.8
  @nrwl/storybook : Not Found
  @nrwl/gatsby : Not Found
  typescript : 4.2.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
AgentEndercommented, Jul 24, 2021

Hey, I’ve been looking into this recently and have almost pinned it down. I could fix it easily by forcing the workspace path to be normalized, but it’s set on project.root currently. I want to figure out what’s causing that to be pulling in a windows path rather than fixing a symptom.

0reactions
Ionarucommented, Jul 24, 2021

Sounds good. Thank you for the quick reply!

Read more comments on GitHub >

github_iconTop Results From Across the Web

workspace.json
Identified the locations of all project in the repo; Contained the target configuration for all projects. Identifying the locations of projects is now...
Read more >
nrwl-nx/community - Gitter
Hello, I have a small issue with an nx-workspace and vscode. Whenever I do imports from libraries, vscode still offers me the relative...
Read more >
Nrwl/Community #support #npm-packages #random
I'm working with builders in the workspace.json file. ... Similar to nx g @nrwl/react:component Login --project=project ?
Read more >
angular this.tree.readtext is not a function
I was trying to make client side angular project to change it to SSR(Server Side Rendering) ... npm i -g create-nx-workspace npx create-nx-workspace...
Read more >
Ng add @nrwl/workspace throws Cannot read property ...
\n' + 'If the error persists, please run "nx reset".' } Turn out there's missing line in file project.json generate by nx {...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found