nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.82k stars 2.27k forks source link

Generators no longer run with `NX Cannot use import statement outside a module` error #20141

Open joelkesler opened 8 months ago

joelkesler commented 8 months ago

Current Behavior

 npx nx g my-generator --name=hello

>  NX  Generating my-plugin:my-generator

 >  NX   Cannot use import statement outside a module

Expected Behavior

The generator should run and generate what it expected

Steps to Reproduce

  1. try and run a previously working generator.

The generator lives in a workspace plugin inside the tools folder:

./tools/workspace-plugin/src/generators

Nx Report

   Node   : 18.16.0
   OS     : darwin-x64
   npm    : 9.5.1

   nx (global)        : 17.0.2
   nx                 : 17.0.2
   @nx/js             : 17.0.2
   @nx/jest           : 17.0.2
   @nx/linter         : 17.0.2
   @nx/eslint         : 17.0.2
   @nx/workspace      : 17.0.2
   @nx/angular        : 17.0.2
   @nx/cypress        : 17.0.2
   @nx/devkit         : 17.0.2
   @nx/eslint-plugin  : 17.0.2
   @nx/plugin         : 17.0.2
   @nx/storybook      : 17.0.2
   @nrwl/tao          : 17.0.2
   @nx/web            : 17.0.2
   @nx/webpack        : 17.0.2
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @ngneat/spectator  : 14.0.0
   @rx-angular/state  : 1.7.0
   @storybook/angular : 7.5.2
   angular-calendar   : 0.31.0
   ng2-charts         : 4.1.1
   ---------------------------------------
   Local workspace plugins:
         @galaxy/workspace-plugin
         my-plugin

Operating System

Additional Information

Generators seems to break often on nx updates.

The ways to use them also changes quite quickly. Most tutorials are well out of date after a year or two. For example, the commands in this helpful article don't work anymore due to breaking changes: https://blog.nrwl.io/using-nx-workspace-generators-to-scaffold-new-blog-posts-8c8162cf857b

skrtheboss commented 8 months ago

Maybe related to #19475

mhelm306 commented 8 months ago

I have a similar issue with using any generator from the @nx/plugin package fails to build due to an improper import in the schema.d.ts for several generators. they import ProjectNameAndRootFormat from '@nx/devkit/src/generators/project-name-directory-utils' which is a file that no longer exists, instead of from '@nx/devkit/src/generators/project-name-and-root-utils'. I can't use any generators or executers from that package until it's fixed.

github-actions[bot] commented 4 days ago

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏