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

[nx/angular] The "path" argument must be of type string. Received null #19182

Closed
1 of 4 tasks
aroncal opened this issue Sep 15, 2023 · 3 comments · Fixed by #19324
Closed
1 of 4 tasks

[nx/angular] The "path" argument must be of type string. Received null #19182

aroncal opened this issue Sep 15, 2023 · 3 comments · Fixed by #19324
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@aroncal
Copy link

aroncal commented Sep 15, 2023

Current Behavior

Trying to generate a component I get this error:

npx nx g @nx/angular:component add-to-cart --project=frontend --path=apps/frontend/src/app/UI/purchase --flat --inline-style --module=catalog --dry-run --verbose

>  NX  Generating @nx/angular:component


 >  NX   The "path" argument must be of type string. Received null


TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
    at new NodeError (node:internal/errors:405:5)
    at validateString (node:internal/validators:162:11)
    at dirname (node:path:1275:5)
    at addToNgModule (/Users/aitor/Documents/workspace/sammicweb-ws/node_modules/@nx/angular/src/generators/utils/find-module.js:49:91)
    at componentGenerator (/Users/aitor/Documents/workspace/sammicweb-ws/node_modules/@nx/angular/src/generators/component/component.js:42:35)
    at /Users/aitor/Documents/workspace/sammicweb-ws/node_modules/nx/src/command-line/generate/generate.js:248:32
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handleErrors (/Users/aitor/Documents/workspace/sammicweb-ws/node_modules/nx/src/utils/params.js:9:16)
    at async Object.handler (/Users/aitor/Documents/workspace/sammicweb-ws/node_modules/nx/src/command-line/generate/command-object.js:13:22)

Expected Behavior

Component should be generated. I actually put the 'path' parameter in the command

GitHub Repo

No response

Steps to Reproduce

Nx Report

nx                 : 16.8.1
   @nx/js             : 16.8.1
   @nx/jest           : 16.8.1
   @nx/linter         : 16.8.1
   @nx/workspace      : 16.8.1
   @nx/angular        : 16.8.1
   @nx/cypress        : 16.8.1
   @nx/devkit         : 16.8.1
   @nx/eslint-plugin  : 16.8.1
   @nx/nest           : 16.8.1
   @nx/node           : 16.8.1
   @nrwl/tao          : 16.8.1
   @nx/webpack        : 16.8.1
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @fortawesome/angular-fontawesome : 0.13.0

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@aroncal
Copy link
Author

aroncal commented Sep 15, 2023

I just figured out what the problem could be:

catalog.module.ts is in a different directory:

apps/frontend/src/app/UI/catalog.module.ts

If I try

npx nx g @nx/angular:component add-to-cart --project=frontend --path=apps/frontend/src/app/UI/catalog --flat --inline-style --module=catalog --dry-run --verbose

it works. Nonetheles, the error is not very clear (I don't know if that's an NG error or a NX error).

@johant87
Copy link

I ran into a similar issue but I think this works as intended, the error message is just not very informing and the argument name of "module" is a bit deceiving. According to the documentation you need to add the filename or path to the NgModule not the the name of the exported Module. Which worked when provided with the correct path.

https://nx.dev/packages/angular/generators/component#module

@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 Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
4 participants