nrwl / nx

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

Workspace generator cannot find /types/@swc/helpers/_/_async_to_generator #20940

Closed kpaxton closed 10 months ago

kpaxton commented 10 months ago

Current Behavior

built a custom generator for my workspace that generates multiple libs, components, state, etc... It was working fine until we updated to nx 17.0.2.

Any time I try to run the generator it now complains:

Error: Cannot find module '../../../../../types/@swc/helpers/_/_async_to_generator'
Require stack:
- /home/kcpaxto/Projects/uee-ui/tools/workspace-plugin/src/generators/domain/generator.ts
- /home/kcpaxto/Projects/uee-ui/node_modules/nx/src/config/schema-utils.js
- /home/kcpaxto/Projects/uee-ui/node_modules/nx/src/command-line/generate/generator-utils.js
- /home/kcpaxto/Projects/uee-ui/node_modules/nx/src/command-line/generate/generate.js
- /home/kcpaxto/Projects/uee-ui/node_modules/nx/src/command-line/generate/command-object.js
- /home/kcpaxto/Projects/uee-ui/node_modules/nx/src/command-line/nx-commands.js
- /home/kcpaxto/Projects/uee-ui/node_modules/nx/bin/init-local.js
- /home/kcpaxto/Projects/uee-ui/node_modules/nx/bin/nx.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1028:15)
    at Function.Module._resolveFilename (/home/kcpaxto/Projects/uee-ui/node_modules/tsconfig-paths/src/register.ts:115:36)
    at Function.Module._load (node:internal/modules/cjs/loader:873:27)
    at Module.require (node:internal/modules/cjs/loader:1100:19)
    at Module.Mod.require (/home/kcpaxto/Projects/uee-ui/node_modules/nx/bin/init-local.js:207:36)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/home/kcpaxto/Projects/uee-ui/tools/workspace-plugin/src/generators/domain/generator.ts:16:29)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Module._compile (/home/kcpaxto/Projects/uee-ui/node_modules/pirates/lib/index.js:117:24)
    at Module._extensions..js (node:internal/modules/cjs/loader:1252:10)

The references in my files are just the import statements.

Expected Behavior

workspace generator executes without error

GitHub Repo

No response

Steps to Reproduce

  1. create custom generator
  2. add imports
    import {
    angularMoveGenerator,
    componentGenerator,
    libraryGenerator,
    ngrxFeatureStoreGenerator
    } from '@nx/angular/generators';
    import {
    ProjectConfiguration,
    Tree,
    formatFiles,
    names,
    readProjectConfiguration,
    updateJson
    } from '@nx/devkit';
    import * as path from 'path';
    import { existsSync } from 'fs';
    import { DomainGeneratorSchema } from './schema'; 
  3. execute generator

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 16.20.2
   OS     : linux-x64
   npm    : 8.19.4

   nx (global)        : 17.2.7
   nx                 : 17.0.3
   @nx/js             : 17.0.3
   @nx/jest           : 17.0.3
   @nx/linter         : 17.0.3
   @nx/eslint         : 17.0.3
   @nx/workspace      : 17.0.3
   @nx/angular        : 17.0.3
   @nx/cypress        : 17.0.3
   @nx/devkit         : 17.0.3
   @nx/eslint-plugin  : 17.0.3
   @nx/node           : 17.0.3
   @nx/plugin         : 17.0.3
   @nx/storybook      : 17.0.3
   @nrwl/tao          : 17.0.3
   @nx/web            : 17.0.3
   @nx/webpack        : 17.0.3
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @compodoc/compodoc               : 1.1.23
   @fortawesome/angular-fontawesome : 0.13.0
   @ngrx/component                  : 16.3.0
   @ngrx/component-store            : 16.3.0
   @ngrx/effects                    : 16.3.0
   @ngrx/entity                     : 16.3.0
   @ngrx/router-store               : 16.3.0
   @ngrx/schematics                 : 16.3.0
   @ngrx/store                      : 16.3.0
   @ngrx/store-devtools             : 16.3.0
   @storybook/angular               : 7.5.1
   @testing-library/angular         : 11.0.4
   ng2-charts                       : 4.1.1
   ---------------------------------------
   Local workspace plugins:
         @uee/workspace-plugin

Failure Logs

No response

Package Manager Version

8.19.4

Operating System

Additional Information

I've tried digging into the referenced files in the error output but I don't see any reference to the module listed in the error.

AgentEnder commented 10 months ago

I would recommend setting NX_PREFER_TS_NODE=true in your environment variables, we will likely move towards that being the default in the future. This could otherwise likely be fixed up by playing with your installed versions of @swc-node/register and @swc/core, to match up with: https://github.com/nrwl/nx/blob/master/packages/js/src/utils/versions.ts

github-actions[bot] commented 9 months ago

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.