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

Remix Crystal Plugin unable to create nodes on Windows #21936

Closed
Coly010 opened this issue Feb 22, 2024 · 6 comments · Fixed by #22837
Closed

Remix Crystal Plugin unable to create nodes on Windows #21936

Coly010 opened this issue Feb 22, 2024 · 6 comments · Fixed by #22837

Comments

@Coly010
Copy link
Contributor

Coly010 commented Feb 22, 2024

          The nx-console extension for vscode is still crashing with the following error when trying to initialize when i have a squeaky clean fresh install of a remix app. I also already made the quick change that @Coly010 recommended.

Windows 11 OS, node 20 LTS, all latest versions as of 22 feb 2024

[Nxls] - 2024-02-22T09:29:03.532Z - Error: Unable to create nodes for apps/remix-app/remix.config.js using plugin @nx/remix/plugin. 

	 Inner Error: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'f:'
    at new NodeError (node:internal/errors:405:5)
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:131:11)
    at defaultLoad (node:internal/modules/esm/load:82:3)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:603:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at #createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at F:\projects\issues\test-suite\node_modules\.pnpm\nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\project-graph\utils\project-configuration-utils.js:156:35
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async Promise.all (index 3)
    at async createProjectConfigurations (F:\projects\issues\test-suite\node_modules\.pnpm\nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\project-graph\utils\retrieve-workspace-files.js:89:62)
    at async processFilesAndCreateAndSerializeProjectGraph (F:\projects\issues\test-suite\node_modules\.pnpm\nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:140:28)
    at async getCachedSerializedProjectGraphPromise (F:\projects\issues\test-suite\node_modules\.pnpm\nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:43:16)
    at async handleRequestProjectGraph (F:\projects\issues\test-suite\node_modules\.pnpm\nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\handle-request-project-graph.js:12:24)
    at async handleResult (F:\projects\issues\test-suite\node_modules\.pnpm\nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\server.js:110:16)
    at async handleMessage (F:\projects\issues\test-suite\node_modules\.pnpm\nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\server.js:81:9)

Originally posted by @binaryartifex in #21714 (comment)

@sowedoO
Copy link

sowedoO commented Feb 26, 2024

I was able to get the project running by changing the file extension to CommonJS (.cjs) -> remix.config.cjs.

You probably wanna update the config so it fits your needs.

/**
 * @type {import('@remix-run/dev').AppConfig}
 */
module.exports = {
  ignoredRouteFiles: ['**/.*'], // appDirectory: "app",
  serverModuleFormat: "esm",
  tailwind: true,
  browserNodeBuiltinsPolyfill: {
    modules: {
      buffer: true, events: true,
      assert: true, util: true, url: true, stream: true, crypto: true, dns: true, net: true, tls: true, string_decoder: true
    }
  },
  watchPaths: () => require('@nx/remix').createWatchPaths(__dirname)
};

@binaryartifex
Copy link

@sowedoO unfortunately that didn't work for me either.

  1. created brand new integrated workspace, no scaffolding projects, just a blank one
  2. installed @nx/remix and created a new app which errors with the above error
  3. attempted your suggestion at renaming to cjs extension
  4. NX console extension cannot generate the projects list. the vscode extension outputs the following logs on startup or reloading the window -
[Nxls] - 2024-03-01T12:40:24.941Z - Retrieving workspace configuration

[Nxls] - 2024-03-01T12:40:25.042Z - Using local Nx package at f:/sandbox/sandbox/node_modules/nx/src/project-graph/project-graph.js

[Nxls] - 2024-03-01T12:40:25.045Z - Using local Nx package at f:/sandbox/sandbox/node_modules/nx/src/project-graph/file-utils.js

[Nxls] - 2024-03-01T12:40:25.046Z - Using local Nx package at f:/sandbox/sandbox/node_modules/nx/src/utils/output.js

[Nxls] - 2024-03-01T12:40:25.046Z - Using local Nx package at f:/sandbox/sandbox/node_modules/nx/src/project-graph/file-map-utils.js

[Nxls] - 2024-03-01T12:40:25.046Z - Using local Nx package at f:/sandbox/sandbox/node_modules/nx/src/daemon/client/client.js

[Nxls] - 2024-03-01T12:40:25.046Z - createProjectGraphAndSourceMapsAsync

[Nxls] - 2024-03-01T12:40:26.055Z - Unable to get project graph

[Nxls] - 2024-03-01T12:40:26.055Z - Error: Unable to create nodes for apps/my-app/remix.config.cjs using plugin @nx/remix/plugin. 

	 Inner Error: f:\sandbox\sandbox\apps\my-app\remix.config.cjs:1
import { dirname } from 'path';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1185:20)
    at Module._compile (node:internal/modules/cjs/loader:1227:27)
    at Object..js (node:internal/modules/cjs/loader:1326:10)
    at Module.load (node:internal/modules/cjs/loader:1126:32)
    at node:internal/modules/cjs/loader:967:12
    at Function._load (node:electron/js2c/node_init:2:13357)
    at Module.require (node:internal/modules/cjs/loader:1150:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at load (F:\sandbox\sandbox\node_modules\.pnpm\@nx+devkit@18.0.6_nx@18.0.6\node_modules\@nx\devkit\src\utils\config-utils.js:65:16)
    at F:\sandbox\sandbox\node_modules\.pnpm\nx@18.0.6_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\project-graph\utils\project-configuration-utils.js:156:35
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async Promise.all (index 1)
    at async createProjectConfigurations (F:\sandbox\sandbox\node_modules\.pnpm\nx@18.0.6_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\project-graph\utils\retrieve-workspace-files.js:89:62)
    at async processFilesAndCreateAndSerializeProjectGraph (F:\sandbox\sandbox\node_modules\.pnpm\nx@18.0.6_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:140:28)
    at async getCachedSerializedProjectGraphPromise (F:\sandbox\sandbox\node_modules\.pnpm\nx@18.0.6_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:43:16)
    at async handleRequestProjectGraph (F:\sandbox\sandbox\node_modules\.pnpm\nx@18.0.6_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\handle-request-project-graph.js:12:24)
    at async handleResult (F:\sandbox\sandbox\node_modules\.pnpm\nx@18.0.6_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\server.js:110:16)
    at async handleMessage (F:\sandbox\sandbox\node_modules\.pnpm\nx@18.0.6_@swc-node+register@1.8.0_@swc+core@1.3.107\node_modules\nx\src\daemon\server\server.js:81:9)

[Nxls] - 2024-03-01T12:40:26.055Z - Resetting daemon client

[Nxls] - 2024-03-01T12:40:26.055Z - Retrieved workspace configuration in: 1114.1792998313904 ms

@binaryartifex
Copy link

revisited this because i really want to use vite within an nx monorepo. managed to at least get it building and running locally with just the rename of the remix config to a .cjs extension and the following in the config at a bare minimum. these changes made straight after scaffolding a new remix app.

/**
 * @type {import('@remix-run/dev').AppConfig}
 */
module.exports = {
  ignoredRouteFiles: ['**/.*'],
  appDirectory: "app",
  // assetsBuildDirectory: "public/build",
  // serverBuildPath: "build/index.js",
  // publicPath: "/build/",
  watchPaths: function () {
    return require('@nx/remix').createWatchPaths(__dirname)
  }
};

@sowedoO
Copy link

sowedoO commented Apr 10, 2024

Just stumbled across the same issue again (new project). Seems like this issue is still not fixed in NX 18.2.3.

@Coly010
Copy link
Contributor Author

Coly010 commented Apr 10, 2024

@sowedoO The release notes would have been updated to indicate if this was fixed, and this issue would have been closed 🙂 .

This is still an issue, and it's on my list, and I will get to it as soon as I can. This issue will be closed when it is merged, and a subsequent release will be made containing the fix.

I can't give you a timeframe on when that will be.

If this is blocking you and you have time and motivation, feel free to open a PR fixing this issue.

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 May 18, 2024
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