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

🐛 Unable to move a library using nx g @nrwl/workspace:move #7642

Closed
bjornharvold opened this issue Nov 7, 2021 · 8 comments · Fixed by #7767
Closed

🐛 Unable to move a library using nx g @nrwl/workspace:move #7642

bjornharvold opened this issue Nov 7, 2021 · 8 comments · Fixed by #7767

Comments

@bjornharvold
Copy link

Current Behavior

I have a directory structure like this:

-libs
  \--extranet
  \--extranet-booking-engine
     \--ui-marketing-slug

I would like to move "ui-marketing-slug" to extranet.

Expected Behavior

Should copy the library to the desired destination

Steps to Reproduce

Trying to move it like this:
nx g @nrwl/workspace:move --project extranet-booking-engine-ui-marketing-slug extranet/ui-marketing-slug

Gives me the error:
path should be a path.relative()d string, but got "."

Trying to move it like this:
nx g @nrwl/workspace:move --project extranet-booking-engine-ui-marketing-slug extranet

Gives me the error:
Invalid destination: [extranet] - Path is not empty.

Environment

Node : 12.22.7
  OS   : darwin x64
  yarn : 1.22.17
  
  nx : 13.1.3
  @nrwl/angular : 13.1.3
  @nrwl/cli : 13.1.3
  @nrwl/cypress : 13.1.3
  @nrwl/devkit : 13.1.3
  @nrwl/eslint-plugin-nx : 13.1.3
  @nrwl/express : Not Found
  @nrwl/jest : 13.1.3
  @nrwl/linter : 13.1.3
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/nx-cloud : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 13.1.3
  @nrwl/web : Not Found
  @nrwl/workspace : 13.1.3
  @nrwl/storybook : 13.1.3
  @nrwl/gatsby : Not Found
  typescript : 4.3.5
@FrozenPandaz FrozenPandaz added the scope: misc Misc issues label Nov 8, 2021
@leosvelperez
Copy link
Member

Thanks for reporting this!

Could you provide a minimal repo with a reproduction? I tried to reproduce it with the above information and I was not able to do so.

@bjornharvold
Copy link
Author

I am trying to recreate in fresh new nx project but am unable to do so. Will close this ticket. However, I am completely unable to move a project in our current monorepo. I always get this error. If there is a way for me to debug this, I would love feedback.

Cheers

@leosvelperez
Copy link
Member

Sorry to hear you're facing those issues.

You can first run the generator with --verbose to get the stack trace of the error and identify where in the generator code is throwing. After you've identified that, you can go to the generator code in node_modules and set up the debugger similarly to what is described here https://nx.dev/l/a/generators/workspace-generators#debugging-workspace-generators.

On a side note, this extranet/ui-marketing-slug would be the right destination to use if you want to have your library root to be libs/extranet/ui-marketing-slug.

@bjornharvold
Copy link
Author

Thank you. Added verbose and got this:

path should be a `path.relative()`d string, but got "."
RangeError: path should be a `path.relative()`d string, but got "."
    at throwError (/Users/crash/git/monorepo/node_modules/ignore/index.js:366:9)
    at checkPath (/Users/crash/git/monorepo/node_modules/ignore/index.js:385:12)
    at Ignore._test (/Users/crash/git/monorepo/node_modules/ignore/index.js:502:5)
    at Ignore.ignores (/Users/crash/git/monorepo/node_modules/ignore/index.js:541:17)
    at Object.visitNotIgnoredFiles (/Users/crash/git/monorepo/node_modules/@nrwl/devkit/src/generators/visit-not-ignored-files.js:15:71)
    at Object.updateImports (/Users/crash/git/monorepo/node_modules/@nrwl/workspace/src/generators/move/lib/update-imports.js:40:22)
    at /Users/crash/git/monorepo/node_modules/@nrwl/workspace/src/generators/move/move.js:28:26
    at Generator.next (<anonymous>)
    at /Users/crash/git/monorepo/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)

Does this give you an insight into where the issue might be?

@leosvelperez
Copy link
Member

leosvelperez commented Nov 17, 2021

It looks like you have a project in your angular.json|workspace.json with "root": "." and https://www.npmjs.com/package/ignore doesn't like that path. I'll push a fix to handle that scenario.

In the meantime, you can change the projects with those paths to be just an empty string, it'll behave the same but the move generator should work with it.

Out of curiosity, what's the use case of having a project root be the workspace root?

@bjornharvold
Copy link
Author

Hi @leosvelperez

I have no idea. This is what my angular.json workspace looks like at the bottom of the file. What should it be??

"workspace": {
      "architect": {
        "version": {
          "builder": "@jscutlery/semver:version",
          "options": {
            "syncVersions": true
          }
        }
      },
      "root": ".",
      "tags": []
    }

@leosvelperez
Copy link
Member

You can just change "root": "." to "root": "".

@github-actions
Copy link

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 Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants