nrwl / nx

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

NextJS Turbopack fails to compile #26510

Open Anyatsu opened 3 months ago

Anyatsu commented 3 months ago

Current Behavior

Running a NextJS app with the --turbo flag fails to compile when entering any page

Expected Behavior

The --turbo flag should work

GitHub Repo

No response

Steps to Reproduce

  1. run npx create-nx-workspace@latest
  2. run development with --turbo flag

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.12.0
OS     : linux-x64
npm    : 10.5.0

nx                 : 19.2.3
@nx/js             : 19.2.3
@nx/jest           : 19.2.3
@nx/linter         : 19.2.3
@nx/eslint         : 19.2.3
@nx/workspace      : 19.2.3
@nx/devkit         : 19.2.3
@nx/eslint-plugin  : 19.2.3
@nx/next           : 19.2.3
@nx/react          : 19.2.3
@nrwl/tao          : 19.2.3
@nx/web            : 19.2.3
@nx/webpack        : 19.2.3
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/next/plugin
@nx/jest/plugin
@nx/eslint/plugin

Failure Logs

> nx run nx-turbo:dev --turbo

> next dev --turbo

  ▲ Next.js 14.2.3 (turbo)
  - Local:        http://localhost:3000

 ✓ Starting...
 ✓ Ready in 2.2s
 ○ Compiling / ...
 ⨯ ./node_modules/nx/src/project-graph/plugins/isolation
Module not found: Can't resolve '/ROOT/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker'
server relative imports are not implemented yet. Please try an import relative to the file you are importing from.

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/project-graph/plugins/isolation/plugin-pool.js:27:20
Module not found: Can't resolve '/ROOT/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker'
  25 |             : {}),
  26 |     };
> 27 |     const worker = (0, child_process_1.fork)(workerPath, [], {
     |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 28 |         stdio: ['ignore', 'inherit', 'inherit', 'ipc'],
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 29 |         env,
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 30 |         execArgv: [
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 31 |             ...process.execArgv,
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 32 |             // If the worker is typescript, we need to register ts-node
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 33 |             ...(isWorkerTypescript ? ['-r', 'ts-node/register'] : []),
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 34 |         ],
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 35 |     });
     | ^^^^^^^
  36 |     worker.send({ type: 'load', payload: { plugin, root } });
  37 |     // logger.verbose(`[plugin-worker] started worker: ${worker.pid}`);
  38 |     const pendingPromises = new Map();

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/tasks-runner
Module not found: Can't resolve '/ROOT/node_modules/nx/src/tasks-runner/batch/run-batch.js'
server relative imports are not implemented yet. Please try an import relative to the file you are importing from.

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/tasks-runner
Module not found: Can't resolve '/ROOT/node_modules/nx/src/tasks-runner/remove-old-cache-records.js'
server relative imports are not implemented yet. Please try an import relative to the file you are importing from.

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/@nx/devkit/src/utils/convert-nx-executor.js:51:12
Module not found: Can't resolve '@angular-devkit/architect'
  49 |         return toObservable(promise());
  50 |     };
> 51 |     return require('@angular-devkit/architect').createBuilder(builderFunction);
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  52 | }
  53 | exports.convertNxExecutor = convertNxExecutor;
  54 | function toObservable(promiseOrAsyncIterator) {

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:109:27
Module not found: Can't resolve '@angular-devkit/architect'
  107 | exports.createBuilderContext = createBuilderContext;
  108 | async function scheduleTarget(root, opts, verbose) {
> 109 |     const { Architect } = require('@angular-devkit/architect');
      |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  110 |     const logger = (0, exports.getLogger)(verbose);
  111 |     const fsHost = new NxScopedHostForBuilders(root);
  112 |     const { workspace } = await core_1.workspaces.readWorkspace('angular.json', core_1.workspaces.createWorkspaceHost(fsHost));

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:38:27
Module not found: Can't resolve '@angular-devkit/architect'
  36 |         return [];
  37 |     });
> 38 |     const { Architect } = require('@angular-devkit/architect');
     |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  39 |     const architect = new Architect(architectHost, registry);
  40 |     const { firstValueFrom } = require('rxjs');
  41 |     const toPromise = (obs) => firstValueFrom ? firstValueFrom(obs) : obs.toPromise();

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:782:129
Module not found: Can't resolve '@angular-devkit/architect/node'
  780 | }
  781 | async function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root, projects) {
> 782 |     const { WorkspaceNodeModulesArchitectHost: AngularWorkspaceNodeModulesArchitectHost, } = await Promise.resolve().then(() => require('@angular-devkit/architect/node'));
      |                                                                                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  783 |     class WrappedWorkspaceNodeModulesArchitectHost extends AngularWorkspaceNodeModulesArchitectHost {
  784 |         constructor(workspace, root, projects) {
  785 |             super(workspace, root);

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:4:16
Module not found: Can't resolve '@angular-devkit/core'
  2 | Object.defineProperty(exports, "__esModule", { value: true });
  3 | exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHostForBuilders = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
> 4 | const core_1 = require("@angular-devkit/core");
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  5 | const node_1 = require("@angular-devkit/core/node");
  6 | const chalk = require("chalk");
  7 | const path_1 = require("path");

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:29:28
Module not found: Can't resolve '@angular-devkit/core'
  27 |     // the top level import is not patched because it is imported before the
  28 |     // patching happens so we require it here to use the patched version below
> 29 |     const { workspaces } = require('@angular-devkit/core');
     |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  30 |     const { workspace } = await workspaces.readWorkspace('angular.json', workspaces.createWorkspaceHost(fsHost));
  31 |     const architectHost = await getWrappedWorkspaceNodeModulesArchitectHost(workspace, context.root, context.projectsConfigurations.projects);
  32 |     const registry = new core_1.schema.CoreSchemaRegistry();

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:5:16
Module not found: Can't resolve '@angular-devkit/core/node'
  3 | exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHostForBuilders = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
  4 | const core_1 = require("@angular-devkit/core");
> 5 | const node_1 = require("@angular-devkit/core/node");
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6 | const chalk = require("chalk");
  7 | const path_1 = require("path");
  8 | const rxjs_1 = require("rxjs");

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:171:56
Module not found: Can't resolve '@angular-devkit/schematics'
  169 |         packageManager: (0, package_manager_1.detectPackageManager)(),
  170 |         root: (0, core_1.normalize)(root),
> 171 |         registry: new core_1.schema.CoreSchemaRegistry(require('@angular-devkit/schematics').formats.standardFormats),
      |                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  172 |         resolvePaths: [process.cwd(), root],
  173 |         engineHostCreator: (options) => createNodeModulesEngineHost(options.resolvePaths, projects),
  174 |     });

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:176:50
Module not found: Can't resolve '@angular-devkit/schematics/tools'
  174 |     });
  175 |     workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
> 176 |     workflow.engineHost.registerOptionsTransform(require('@angular-devkit/schematics/tools').validateOptionsWithSchema(workflow.registry));
      |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  177 |     if (opts.interactive) {
  178 |         workflow.registry.usePromptProvider(createPromptProvider());
  179 |     }

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:165:26
Module not found: Can't resolve '@angular-devkit/schematics/tools'
  163 | }
  164 | function createWorkflow(fsHost, root, opts, projects) {
> 165 |     const NodeWorkflow = require('@angular-devkit/schematics/tools').NodeWorkflow;
      |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  166 |     const workflow = new NodeWorkflow(fsHost, {
  167 |         force: false,
  168 |         dryRun: opts.dryRun,

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:134:35
Module not found: Can't resolve '@angular-devkit/schematics/tools'
  132 | exports.scheduleTarget = scheduleTarget;
  133 | function createNodeModulesEngineHost(resolvePaths, projects) {
> 134 |     const NodeModulesEngineHost = require('@angular-devkit/schematics/tools')
      |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  135 |         .NodeModulesEngineHost;
  136 |     class NxNodeModulesEngineHost extends NodeModulesEngineHost {
  137 |         constructor() {

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/@swc/core/index.js:68:28
Module not found: Can't resolve '@swc/wasm'
  66 |     catch (_) {
  67 |         // postinstall supposed to install `@swc/wasm` already
> 68 |         fallbackBindings = require("@swc/wasm");
     |                            ^^^^^^^^^^^^^^^^^^^^
  69 |     }
  70 |     finally {
  71 |         return binding;

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/prettier/third-party.js:83:34
Module not found
  81 |       delete require.cache[filePath];
  82 |       const parent = require.cache[parentPath];
> 83 |       return parent === void 0 ? require(filePath) : parent.require(filePath);
     |                                  ^^^^^^^^^^^^^^^^^
  84 |     };
  85 |   }
  86 | });

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/prettier/index.js:38143:10
Module not found
  38141 |       const externalPlugins = [...uniqByKey([...externalManualLoadPluginInfos, ...externalAutoLoadPluginInfos], "requirePath").map((externalPluginInfo) => Object.assign({
  38142 |         name: externalPluginInfo.name
> 38143 |       }, require(externalPluginInfo.requirePath))), ...externalPluginInstances];
        |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  38144 |       return [...internalPlugins, ...externalPlugins];
  38145 |     }
  38146 |     function findPluginsInNodeModules(nodeModulesDir) {

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:588:26
Module not found
  586 |     }
  587 |     if ((0, path_1.extname)(name)) {
> 588 |         collectionPath = require.resolve(name);
      |                          ^^^^^^^^^^^^^^^^^^^^^
  589 |     }
  590 |     else {
  591 |         const { path: packageJsonPath, packageJson } = (0, package_json_1.readModulePackageJson)(name, (0, installation_directory_1.getNxRequirePaths)(process.cwd()));

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/yargs-parser/build/index.cjs:1029:20
Module not found
  1027 |     require: (path) => {
  1028 |         if (typeof require !== 'undefined') {
> 1029 |             return require(path);
       |                    ^^^^^^^^^^^^^
  1030 |         }
  1031 |         else if (path.match(/\.json$/)) {
  1032 |             return JSON.parse(fs.readFileSync(path, 'utf8'));

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:153:38
Module not found
  151 |                     throw new Error(`The "${name}" package does not support Nx generators or Angular Devkit schematics.`);
  152 |                 }
> 153 |                 collectionFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), schematics ?? generators));
      |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  154 |             }
  155 |             return collectionFilePath;
  156 |         }

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/native/index.js:53:28
Module not found
  51 |     localNodeFiles.some((f) => modulePath.endsWith(f))
  52 |   ) {
> 53 |     const nativeLocation = require.resolve(modulePath);
     |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  54 |     const fileName = basename(nativeLocation);
  55 |
  56 |     // we copy the file to a workspace-scoped tmp directory and prefix with nxVersion to avoid stale files being loaded

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/tsconfig-paths/lib/filesystem.js:31:12
Module not found
  29 |     }
  30 |     // eslint-disable-next-line @typescript-eslint/no-require-imports
> 31 |     return require(packageJsonPath);
     |            ^^^^^^^^^^^^^^^^^^^^^^^^
  32 | }
  33 | exports.readJsonFromDiskSync = readJsonFromDiskSync;
  34 | function readJsonFromDiskAsync(path,

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/ts-node/dist-raw/node-internal-modules-cjs-helpers.js:67:21
Module not found
  65 |       get: () => {
  66 |         // Node 12 hack; remove when we drop node12 support
> 67 |         const lib = (dummyModule.require || require)(name);
     |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  68 |
  69 |         // Disable the current getter/setter and set up a new
  70 |         // non-enumerable property.

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/adapter/ngcli-adapter.js:808:39
Module not found
  806 |                 throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
  807 |             }
> 808 |             const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
      |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  809 |             const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
  810 |             const executorConfig = executorsJson.builders?.[builder] ?? executorsJson.executors?.[builder];
  811 |             if (!executorConfig) {

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/command-line/run/executor-utils.js:65:31
Module not found
  63 |         throw new Error(`The "${nodeModule}" package does not support Nx executors.`);
  64 |     }
> 65 |     const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  66 |     const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
  67 |     const executorConfig = executorsJson.executors?.[executor] || executorsJson.builders?.[executor];
  68 |     if (!executorConfig) {

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/project-graph/plugins/loader.js:212:64
Module not found
  210 | exports.loadNxPluginAsync = loadNxPluginAsync;
  211 | async function importPluginModule(pluginPath) {
> 212 |     const m = await Promise.resolve(`${pluginPath}`).then(s => require(s));
      |                                                                ^^^^^^^^^^
  213 |     if (m.default &&
  214 |         ('createNodes' in m.default || 'createDependencies' in m.default)) {
  215 |         return m.default;

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/prettier/index.js:18428:31
Module not found
  18426 |                 paths: [dir]
  18427 |               });
> 18428 |               result.config = require(modulePath);
        |                               ^^^^^^^^^^^^^^^^^^^
  18429 |             }
  18430 |             if (typeof result.config !== "object") {
  18431 |               throw new TypeError(`Config is only allowed to be an object, but received ${typeof result.config} in "${result.filepath}"`);

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/ts-node/dist/transpilers/swc.js:12:23
Module not found
  10 |     if (typeof swc === 'string') {
  11 |         swcDepName = swc;
> 12 |         swcInstance = require(transpilerConfigLocalResolveHelper(swc, true));
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  13 |     }
  14 |     else if (swc == null) {
  15 |         let swcResolved;

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/ts-node/dist/index.js:247:39
Module not found
  245 |                 : projectLocalResolveHelper;
  246 |             const transpilerPath = transpilerConfigLocalResolveHelper(transpilerName, true);
> 247 |             const transpilerFactory = require(transpilerPath)
      |                                       ^^^^^^^^^^^^^^^^^^^^^^^
  248 |                 .create;
  249 |             return createTranspiler;
  250 |             function createTranspiler(compilerOptions, nodeModuleEmitKind) {

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/ts-node/dist/transpilers/swc.js:29:23
Module not found
  27 |             }
  28 |         }
> 29 |         swcInstance = require(swcResolved);
     |                       ^^^^^^^^^^^^^^^^^^^^
  30 |     }
  31 |     else {
  32 |         swcInstance = swc;

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/@nx/devkit/src/utils/package-json.js:370:12
Module not found
  368 | }
  369 | function getPackageVersion(pkg) {
> 370 |     return require((0, path_1.join)(pkg, 'package.json')).version;
      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  371 | }
  372 | /**
  373 |  * @description The version of Nx used by the workspace. Returns null if no version is found.

https://nextjs.org/docs/messages/module-not-found

 ⨯ ./node_modules/nx/src/config/schema-utils.js:20:24
Module not found
  18 |             (0, plugins_1.registerPluginTSTranspiler)();
  19 |         }
> 20 |         const module = require(modulePath);
     |                        ^^^^^^^^^^^^^^^^^^^
  21 |         return implementationExportName
  22 |             ? module[implementationExportName]
  23 |             : module.default ?? module;

https://nextjs.org/docs/messages/module-not-found

 ✓ Compiled / in 29.2s
 ⨯ ModuleBuildError: ./node_modules/nx/src/project-graph/plugins/isolation
Module not found: Can't resolve '/ROOT/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker'
server relative imports are not implemented yet. Please try an import relative to the file you are importing from.

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/project-graph/plugins/isolation/plugin-pool.js:27:20
Module not found: Can't resolve '/ROOT/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker'
  25 |             : {}),
  26 |     };
> 27 |     const worker = (0, child_process_1.fork)(workerPath, [], {
     |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 28 |         stdio: ['ignore', 'inherit', 'inherit', 'ipc'],
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 29 |         env,
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 30 |         execArgv: [
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 31 |             ...process.execArgv,
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 32 |             // If the worker is typescript, we need to register ts-node
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 33 |             ...(isWorkerTypescript ? ['-r', 'ts-node/register'] : []),
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 34 |         ],
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 35 |     });
     | ^^^^^^^
  36 |     worker.send({ type: 'load', payload: { plugin, root } });
  37 |     // logger.verbose(`[plugin-worker] started worker: ${worker.pid}`);
  38 |     const pendingPromises = new Map();

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/tasks-runner
Module not found: Can't resolve '/ROOT/node_modules/nx/src/tasks-runner/batch/run-batch.js'
server relative imports are not implemented yet. Please try an import relative to the file you are importing from.

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/tasks-runner
Module not found: Can't resolve '/ROOT/node_modules/nx/src/tasks-runner/remove-old-cache-records.js'
server relative imports are not implemented yet. Please try an import relative to the file you are importing from.

https://nextjs.org/docs/messages/module-not-found

./node_modules/@nx/devkit/src/utils/convert-nx-executor.js:51:12
Module not found: Can't resolve '@angular-devkit/architect'
  49 |         return toObservable(promise());
  50 |     };
> 51 |     return require('@angular-devkit/architect').createBuilder(builderFunction);
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  52 | }
  53 | exports.convertNxExecutor = convertNxExecutor;
  54 | function toObservable(promiseOrAsyncIterator) {

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:109:27
Module not found: Can't resolve '@angular-devkit/architect'
  107 | exports.createBuilderContext = createBuilderContext;
  108 | async function scheduleTarget(root, opts, verbose) {
> 109 |     const { Architect } = require('@angular-devkit/architect');
      |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  110 |     const logger = (0, exports.getLogger)(verbose);
  111 |     const fsHost = new NxScopedHostForBuilders(root);
  112 |     const { workspace } = await core_1.workspaces.readWorkspace('angular.json', core_1.workspaces.createWorkspaceHost(fsHost));

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:38:27
Module not found: Can't resolve '@angular-devkit/architect'
  36 |         return [];
  37 |     });
> 38 |     const { Architect } = require('@angular-devkit/architect');
     |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  39 |     const architect = new Architect(architectHost, registry);
  40 |     const { firstValueFrom } = require('rxjs');
  41 |     const toPromise = (obs) => firstValueFrom ? firstValueFrom(obs) : obs.toPromise();

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:782:129
Module not found: Can't resolve '@angular-devkit/architect/node'
  780 | }
  781 | async function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root, projects) {
> 782 |     const { WorkspaceNodeModulesArchitectHost: AngularWorkspaceNodeModulesArchitectHost, } = await Promise.resolve().then(() => require('@angular-devkit/architect/node'));
      |                                                                                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  783 |     class WrappedWorkspaceNodeModulesArchitectHost extends AngularWorkspaceNodeModulesArchitectHost {
  784 |         constructor(workspace, root, projects) {
  785 |             super(workspace, root);

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:4:16
Module not found: Can't resolve '@angular-devkit/core'
  2 | Object.defineProperty(exports, "__esModule", { value: true });
  3 | exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHostForBuilders = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
> 4 | const core_1 = require("@angular-devkit/core");
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  5 | const node_1 = require("@angular-devkit/core/node");
  6 | const chalk = require("chalk");
  7 | const path_1 = require("path");

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:29:28
Module not found: Can't resolve '@angular-devkit/core'
  27 |     // the top level import is not patched because it is imported before the
  28 |     // patching happens so we require it here to use the patched version below
> 29 |     const { workspaces } = require('@angular-devkit/core');
     |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  30 |     const { workspace } = await workspaces.readWorkspace('angular.json', workspaces.createWorkspaceHost(fsHost));
  31 |     const architectHost = await getWrappedWorkspaceNodeModulesArchitectHost(workspace, context.root, context.projectsConfigurations.projects);
  32 |     const registry = new core_1.schema.CoreSchemaRegistry();

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:5:16
Module not found: Can't resolve '@angular-devkit/core/node'
  3 | exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHostForBuilders = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
  4 | const core_1 = require("@angular-devkit/core");
> 5 | const node_1 = require("@angular-devkit/core/node");
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6 | const chalk = require("chalk");
  7 | const path_1 = require("path");
  8 | const rxjs_1 = require("rxjs");

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:171:56
Module not found: Can't resolve '@angular-devkit/schematics'
  169 |         packageManager: (0, package_manager_1.detectPackageManager)(),
  170 |         root: (0, core_1.normalize)(root),
> 171 |         registry: new core_1.schema.CoreSchemaRegistry(require('@angular-devkit/schematics').formats.standardFormats),
      |                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  172 |         resolvePaths: [process.cwd(), root],
  173 |         engineHostCreator: (options) => createNodeModulesEngineHost(options.resolvePaths, projects),
  174 |     });

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:176:50
Module not found: Can't resolve '@angular-devkit/schematics/tools'
  174 |     });
  175 |     workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
> 176 |     workflow.engineHost.registerOptionsTransform(require('@angular-devkit/schematics/tools').validateOptionsWithSchema(workflow.registry));
      |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  177 |     if (opts.interactive) {
  178 |         workflow.registry.usePromptProvider(createPromptProvider());
  179 |     }

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:165:26
Module not found: Can't resolve '@angular-devkit/schematics/tools'
  163 | }
  164 | function createWorkflow(fsHost, root, opts, projects) {
> 165 |     const NodeWorkflow = require('@angular-devkit/schematics/tools').NodeWorkflow;
      |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  166 |     const workflow = new NodeWorkflow(fsHost, {
  167 |         force: false,
  168 |         dryRun: opts.dryRun,

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:134:35
Module not found: Can't resolve '@angular-devkit/schematics/tools'
  132 | exports.scheduleTarget = scheduleTarget;
  133 | function createNodeModulesEngineHost(resolvePaths, projects) {
> 134 |     const NodeModulesEngineHost = require('@angular-devkit/schematics/tools')
      |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  135 |         .NodeModulesEngineHost;
  136 |     class NxNodeModulesEngineHost extends NodeModulesEngineHost {
  137 |         constructor() {

https://nextjs.org/docs/messages/module-not-found

./node_modules/@swc/core/index.js:68:28
Module not found: Can't resolve '@swc/wasm'
  66 |     catch (_) {
  67 |         // postinstall supposed to install `@swc/wasm` already
> 68 |         fallbackBindings = require("@swc/wasm");
     |                            ^^^^^^^^^^^^^^^^^^^^
  69 |     }
  70 |     finally {
  71 |         return binding;

https://nextjs.org/docs/messages/module-not-found

./node_modules/prettier/third-party.js:83:34
Module not found
  81 |       delete require.cache[filePath];
  82 |       const parent = require.cache[parentPath];
> 83 |       return parent === void 0 ? require(filePath) : parent.require(filePath);
     |                                  ^^^^^^^^^^^^^^^^^
  84 |     };
  85 |   }
  86 | });

https://nextjs.org/docs/messages/module-not-found

./node_modules/prettier/index.js:38143:10
Module not found
  38141 |       const externalPlugins = [...uniqByKey([...externalManualLoadPluginInfos, ...externalAutoLoadPluginInfos], "requirePath").map((externalPluginInfo) => Object.assign({
  38142 |         name: externalPluginInfo.name
> 38143 |       }, require(externalPluginInfo.requirePath))), ...externalPluginInstances];
        |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  38144 |       return [...internalPlugins, ...externalPlugins];
  38145 |     }
  38146 |     function findPluginsInNodeModules(nodeModulesDir) {

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:588:26
Module not found
  586 |     }
  587 |     if ((0, path_1.extname)(name)) {
> 588 |         collectionPath = require.resolve(name);
      |                          ^^^^^^^^^^^^^^^^^^^^^
  589 |     }
  590 |     else {
  591 |         const { path: packageJsonPath, packageJson } = (0, package_json_1.readModulePackageJson)(name, (0, installation_directory_1.getNxRequirePaths)(process.cwd()));

https://nextjs.org/docs/messages/module-not-found

./node_modules/yargs-parser/build/index.cjs:1029:20
Module not found
  1027 |     require: (path) => {
  1028 |         if (typeof require !== 'undefined') {
> 1029 |             return require(path);
       |                    ^^^^^^^^^^^^^
  1030 |         }
  1031 |         else if (path.match(/\.json$/)) {
  1032 |             return JSON.parse(fs.readFileSync(path, 'utf8'));

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:153:38
Module not found
  151 |                     throw new Error(`The "${name}" package does not support Nx generators or Angular Devkit schematics.`);
  152 |                 }
> 153 |                 collectionFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), schematics ?? generators));
      |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  154 |             }
  155 |             return collectionFilePath;
  156 |         }

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/native/index.js:53:28
Module not found
  51 |     localNodeFiles.some((f) => modulePath.endsWith(f))
  52 |   ) {
> 53 |     const nativeLocation = require.resolve(modulePath);
     |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  54 |     const fileName = basename(nativeLocation);
  55 |
  56 |     // we copy the file to a workspace-scoped tmp directory and prefix with nxVersion to avoid stale files being loaded

https://nextjs.org/docs/messages/module-not-found

./node_modules/tsconfig-paths/lib/filesystem.js:31:12
Module not found
  29 |     }
  30 |     // eslint-disable-next-line @typescript-eslint/no-require-imports
> 31 |     return require(packageJsonPath);
     |            ^^^^^^^^^^^^^^^^^^^^^^^^
  32 | }
  33 | exports.readJsonFromDiskSync = readJsonFromDiskSync;
  34 | function readJsonFromDiskAsync(path,

https://nextjs.org/docs/messages/module-not-found

./node_modules/ts-node/dist-raw/node-internal-modules-cjs-helpers.js:67:21
Module not found
  65 |       get: () => {
  66 |         // Node 12 hack; remove when we drop node12 support
> 67 |         const lib = (dummyModule.require || require)(name);
     |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  68 |
  69 |         // Disable the current getter/setter and set up a new
  70 |         // non-enumerable property.

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/adapter/ngcli-adapter.js:808:39
Module not found
  806 |                 throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
  807 |             }
> 808 |             const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
      |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  809 |             const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
  810 |             const executorConfig = executorsJson.builders?.[builder] ?? executorsJson.executors?.[builder];
  811 |             if (!executorConfig) {

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/command-line/run/executor-utils.js:65:31
Module not found
  63 |         throw new Error(`The "${nodeModule}" package does not support Nx executors.`);
  64 |     }
> 65 |     const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  66 |     const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
  67 |     const executorConfig = executorsJson.executors?.[executor] || executorsJson.builders?.[executor];
  68 |     if (!executorConfig) {

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/project-graph/plugins/loader.js:212:64
Module not found
  210 | exports.loadNxPluginAsync = loadNxPluginAsync;
  211 | async function importPluginModule(pluginPath) {
> 212 |     const m = await Promise.resolve(`${pluginPath}`).then(s => require(s));
      |                                                                ^^^^^^^^^^
  213 |     if (m.default &&
  214 |         ('createNodes' in m.default || 'createDependencies' in m.default)) {
  215 |         return m.default;

https://nextjs.org/docs/messages/module-not-found

./node_modules/prettier/index.js:18428:31
Module not found
  18426 |                 paths: [dir]
  18427 |               });
> 18428 |               result.config = require(modulePath);
        |                               ^^^^^^^^^^^^^^^^^^^
  18429 |             }
  18430 |             if (typeof result.config !== "object") {
  18431 |               throw new TypeError(`Config is only allowed to be an object, but received ${typeof result.config} in "${result.filepath}"`);

https://nextjs.org/docs/messages/module-not-found

./node_modules/ts-node/dist/transpilers/swc.js:12:23
Module not found
  10 |     if (typeof swc === 'string') {
  11 |         swcDepName = swc;
> 12 |         swcInstance = require(transpilerConfigLocalResolveHelper(swc, true));
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  13 |     }
  14 |     else if (swc == null) {
  15 |         let swcResolved;

https://nextjs.org/docs/messages/module-not-found

./node_modules/ts-node/dist/index.js:247:39
Module not found
  245 |                 : projectLocalResolveHelper;
  246 |             const transpilerPath = transpilerConfigLocalResolveHelper(transpilerName, true);
> 247 |             const transpilerFactory = require(transpilerPath)
      |                                       ^^^^^^^^^^^^^^^^^^^^^^^
  248 |                 .create;
  249 |             return createTranspiler;
  250 |             function createTranspiler(compilerOptions, nodeModuleEmitKind) {

https://nextjs.org/docs/messages/module-not-found

./node_modules/ts-node/dist/transpilers/swc.js:29:23
Module not found
  27 |             }
  28 |         }
> 29 |         swcInstance = require(swcResolved);
     |                       ^^^^^^^^^^^^^^^^^^^^
  30 |     }
  31 |     else {
  32 |         swcInstance = swc;

https://nextjs.org/docs/messages/module-not-found

./node_modules/@nx/devkit/src/utils/package-json.js:370:12
Module not found
  368 | }
  369 | function getPackageVersion(pkg) {
> 370 |     return require((0, path_1.join)(pkg, 'package.json')).version;
      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  371 | }
  372 | /**
  373 |  * @description The version of Nx used by the workspace. Returns null if no version is found.

https://nextjs.org/docs/messages/module-not-found

./node_modules/nx/src/config/schema-utils.js:20:24
Module not found
  18 |             (0, plugins_1.registerPluginTSTranspiler)();
  19 |         }
> 20 |         const module = require(modulePath);
     |                        ^^^^^^^^^^^^^^^^^^^
  21 |         return implementationExportName
  22 |             ? module[implementationExportName]
  23 |             : module.default ?? module;

https://nextjs.org/docs/messages/module-not-found

    at processIssues (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/dev/turbopack-utils.js:229:15)
    at handleRouteType (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/dev/turbopack-utils.js:386:17)
    at async Object.ensurePage (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/dev/hot-reloader-turbopack.js:644:17)
    at async DevBundlerService.ensurePage (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/lib/dev-bundler-service.js:18:20)
    at async DevServer.ensurePage (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/dev/next-dev-server.js:551:9)
    at async Object.ensure (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/dev/next-dev-server.js:169:17)
    at async DevRouteMatcherManager.matchAll (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/future/route-matcher-managers/dev-route-matcher-manager.js:96:13)
    at async DevRouteMatcherManager.match (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/future/route-matcher-managers/default-route-matcher-manager.js:155:26)
    at async NextNodeServer.handleCatchallRenderRequest (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/next-server.js:228:31)
    at async DevServer.handleRequestImpl (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/base-server.js:816:17)
    at async /home/yuval/projects/nx-turbo/node_modules/next/dist/server/dev/next-dev-server.js:339:20
    at async Span.traceAsyncFn (/home/yuval/projects/nx-turbo/node_modules/next/dist/trace/trace.js:154:20)
    at async DevServer.handleRequest (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/dev/next-dev-server.js:336:24)
    at async invokeRender (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/lib/router-server.js:174:21)
    at async handleRequest (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/lib/router-server.js:353:24)
    at async requestHandlerImpl (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/lib/router-server.js:377:13)
    at async Server.requestListener (/home/yuval/projects/nx-turbo/node_modules/next/dist/server/lib/start-server.js:141:13)
 ○ Compiling /_error ...
 ✓ Compiled /_error in 1979ms
 GET / 500 in 32076ms

Package Manager Version

No response

Operating System

Additional Information

Same result using both WSL Fedora Remix 39.01 and Windows

fernandoMendozaMM commented 3 months ago

I'm also facing the same issue, not even sure what caused it because I think it was working fine before.

cyrus-za commented 3 months ago

Also facing this. Not sure why we even got angular devkit in the mix as there's no angular code in the repo. I guess nx is using some code from angular to handle its monorepo orchestration

ndcunningham commented 3 months ago

Hi, I think this is an issue with Next.js / turbopack and not necessarily Nx. I opened an issue on Next.js GH about it: https://github.com/vercel/next.js/issues/66602

Waiting for the Vercel team to address it or communicate about what can be done.

mxa0079 commented 1 month ago

Thanks @ndcunningham - however the issue you linked seems to be purely related to Tailwind.

In this case the logs are showing errors importing Angular modules within a nx adaptar, for a repo that does not have any angular projects in it.

So is this a different issue?

Is turbopack not working for NX at the moment? Do we know which one was the last version on which it was supported? Is there a known workaround?

jgalbsss commented 1 month ago

bumping this, same issue

duarte2377 commented 1 month ago

same issue with next-i18next package