Skip to content

@nrwl/workspace:move fails on tsconfig.json with comments #13740

Closed
@Den-dp

Description

@Den-dp
Contributor

Current Behavior

@nrwl/workspace:move generator fails while trying to move around a lib in a newly created (via angular cli) project, since from the start tsconfig.json has comments inside (I guess it affects all newcomers trying to use nx in their projects).

Expected Behavior

npx nx generate @nrwl/workspace:move libs --project-name=some-lib --verbose

should work with tsconfig.json which uses json5 file format (comments).

Github Repo

No response

Steps to Reproduce

  1. ng new ng14-minimal --minimal --inline-style --inline-template --skip-tests --routing false --style=css
  2. cd ng14-minimal
  3. ng g library some-lib
  4. cat tsconfig.json
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "compileOnSave": false,
  1. npm i @nrwl/workspace -D
  2. npx nx generate @nrwl/workspace:move libs --project-name=some-lib --verbose

Nx Report

>  NX   Report complete - copy this into the issue template

   Node : 14.20.0
   OS   : win32 x64
   npm  : 6.14.17

   nx : 15.3.0
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.3.0
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : Not Found
   @nrwl/js : Not Found
   @nrwl/linter : 15.3.0
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : Not Found
   @nrwl/workspace : 15.3.0
   typescript : 4.7.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

Failure Logs

npx nx generate @nrwl/workspace:move libs --project-name=some-lib --verbose

>  NX  Generating @nrwl/workspace:move


 >  NX   Unexpected token / in JSON at position 0


SyntaxError: Unexpected token / in JSON at position 0
    at JSON.parse (<anonymous>)
    at updateImports (C:\temp\ng14-minimal\node_modules\@nrwl\workspace\src\generators\move\lib\update-imports.js:29:25)
    at C:\temp\ng14-minimal\node_modules\@nrwl\workspace\src\generators\move\move.js:28:44
    at Generator.next (<anonymous>)
    at C:\temp\ng14-minimal\node_modules\tslib\tslib.js:118:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\temp\ng14-minimal\node_modules\tslib\tslib.js:114:16)
    at moveGenerator (C:\temp\ng14-minimal\node_modules\@nrwl\workspace\src\generators\move\move.js:22:20)
    at Object.<anonymous> (C:\temp\ng14-minimal\node_modules\nx\src\command-line\generate.js:222:36)
    at Generator.next (<anonymous>)

Additional Information

No response

Activity

Coly010

Coly010 commented on Dec 14, 2022

@Coly010
Contributor

There's a specific move generator for Angular workspaces

nx g @nrwl/angular:move

Can you try that instead? https://nx.dev/packages/angular/generators/move

Den-dp

Den-dp commented on Dec 15, 2022

@Den-dp
ContributorAuthor

@Coly010 unfortunately I see the same error

image

looks like internally it uses @nrwl/workspace:move anyway

import { convertNxGenerator, formatFiles, Tree } from '@nrwl/devkit';
import { moveGenerator } from '@nrwl/workspace/generators';
import { updateModuleName } from './lib/update-module-name';
import { updateNgPackage } from './lib/update-ng-package';
import { Schema } from './schema';
/**
* Moves an Angular lib/app to another folder (and renames it in the process)
*
* @remarks It's important to note that `updateModuleName` is done after the update
* to the workspace, so it can't use the same tricks as the `@nrwl/workspace` rules
* to get the before and after names and paths.
*/
export async function angularMoveGenerator(
tree: Tree,
schema: Schema
): Promise<void> {
await moveGenerator(tree, { ...schema, skipFormat: true });
updateModuleName(tree, schema);
updateNgPackage(tree, schema);
if (!schema.skipFormat) {
await formatFiles(tree);
}
}

Coly010

Coly010 commented on Dec 15, 2022

@Coly010
Contributor

It does, but it does extra things required for angular, let me take a look

github-actions

github-actions commented on Mar 21, 2023

@github-actions

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.

2 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Den-dp@AgentEnder@Coly010

      Issue actions

        @nrwl/workspace:move fails on tsconfig.json with comments · Issue #13740 · nrwl/nx