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

Error serving standalone app (fastify, express) #16831

Closed
1 of 4 tasks
lucas-labs opened this issue May 6, 2023 · 8 comments
Closed
1 of 4 tasks

Error serving standalone app (fastify, express) #16831

lucas-labs opened this issue May 6, 2023 · 8 comments

Comments

@lucas-labs
Copy link

lucas-labs commented May 6, 2023

Current Behavior

> nx run repro:serve:development

[ watch ] build succeeded, watching for changes...
Debugger listening on ws://localhost:9229/f630444b-c355-463a-85f8-dded6237a6e5
Debugger listening on ws://localhost:9229/f630444b-c355-463a-85f8-dded6237a6e5
For help, see: https://nodejs.org/en/docs/inspector
Error: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
    at new NodeError (node:internal/errors:399:5)
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1059:11)
    at defaultResolve (node:internal/modules/esm/resolve:1135:3)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ESMLoader.import (node:internal/modules/esm/loader:525:22)
    at importModuleDynamically (node:internal/modules/cjs/loader:1186:29)
    at importModuleDynamicallyWrapper (node:internal/vm/module:429:21)
    at importModuleDynamically (node:internal/vm:106:46)

Expected Behavior

It should serve the app

GitHub Repo

https://github.com/lucas-labs/nx-issue-repro

Steps to Reproduce

  1. Create the workspace selecting node-standalone - fastify
$ npx create-nx-workspace@latest

 >  NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

√ Choose what to create                 · node-standalone
√ Application name                      · repro
√ What framework should be used? · fastify
√ Would you like to generate a Dockerfile? [https://docs.docker.com/] · No
√ Enable distributed caching to make your CI faster · No
  1. Serve the app: npm run start (nx run repro:serve:development)

Nx Report

Node   : 20.1.0
   OS     : win32 x64
   npm    : 9.6.4
   Hasher : Native

   nx (global)        : 16.1.1
   nx                 : 16.1.1
   @nx/js             : 16.1.1
   @nx/jest           : 16.1.1
   @nx/linter         : 16.1.1
   @nx/workspace      : 16.1.1
   @nx/devkit         : 16.1.1
   @nx/esbuild        : 16.1.1
   @nx/eslint-plugin  : 16.1.1
   @nx/node           : 16.1.1
   @nrwl/tao          : 16.1.1
   typescript         : 5.0.4

Failure Logs

> nx run repro:serve:development

[ watch ] build succeeded, watching for changes...
Debugger listening on ws://localhost:9229/d12b87a6-7ed6-4627-a235-b2d0e217f819
Debugger listening on ws://localhost:9229/d12b87a6-7ed6-4627-a235-b2d0e217f819
For help, see: https://nodejs.org/en/docs/inspector
Error: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
    at new NodeError (node:internal/errors:399:5)
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:972:11)
    at defaultResolve (node:internal/modules/esm/resolve:1051:3)
    at DefaultModuleLoader.resolve (node:internal/modules/esm/loader:307:12)
    at DefaultModuleLoader.getModuleJob (node:internal/modules/esm/loader:156:32)
    at DefaultModuleLoader.import (node:internal/modules/esm/loader:266:12)
    at importModuleDynamically (node:internal/modules/cjs/loader:1197:37)
    at importModuleDynamicallyWrapper (node:internal/vm/module:428:21)
    at importModuleDynamically (node:internal/vm:105:46)
    at importModuleDynamicallyCallback (node:internal/modules/esm/utils:87:14)

Operating System

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

Additional Information

Searching old issues I found that a similar error happened with Node < v14. Tried with node versions: 20.1.0, 20.0.0, 18.16.0 and 16.14.0 and got the same error message.

@ZenSoftware
Copy link

I am getting the same error while trying to serve my Nest app after upgrading Nx from v16.1.0 to v16.1.1. I have tried this on both Node v18 and Node v20 and the issue occurs on both. Reverting to v16.1.0 resolves the issue.

Nx Report

   Node   : 20.1.0
   OS     : win32 x64
   pnpm   : 8.3.1
   Hasher : Native

   nx                 : 16.1.1
   @nx/js             : 16.1.1
   @nx/jest           : 16.1.1
   @nx/linter         : 16.1.1
   @nx/workspace      : 16.1.1
   @nx/angular        : 16.1.1
   @nx/cypress        : 16.1.1
   @nx/devkit         : 16.1.1
   @nx/eslint-plugin  : 16.1.1
   @nx/nest           : 16.1.1
   @nx/node           : 16.1.1
   @nx/storybook      : 16.1.1
   @nrwl/tao          : 16.1.1
   @nx/webpack        : 16.1.1
   typescript         : 5.0.4
   ---------------------------------------
   Community plugins:
   @storybook/angular : 7.0.9
   apollo-angular     : 4.2.1

Operating System

  • Windows

@B1Z1
Copy link

B1Z1 commented May 6, 2023

Same problem on windows 11

@WarrenMfg
Copy link

Same for macOS


> nx run express:serve:development


 >  NX   Cannot find module 'ajv/dist/compile/codegen'

   Require stack:
   - /Users/kennethwarren/Desktop/wmfg/node_modules/ajv-keywords/dist/definitions/typeof.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/ajv-keywords/dist/keywords/typeof.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/ajv-keywords/dist/keywords/index.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/ajv-keywords/dist/index.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/schema-utils/dist/validate.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/schema-utils/dist/index.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/copy-webpack-plugin/dist/index.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/@nx/webpack/src/utils/create-copy-plugin.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/@nx/webpack/src/utils/with-nx.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/@nx/webpack/src/executors/webpack/lib/get-webpack-config.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/@nx/webpack/src/executors/webpack/webpack.impl.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/nx/src/config/workspaces.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/nx/src/command-line/run.js
   - /Users/kennethwarren/Desktop/wmfg/node_modules/nx/bin/run-executor.js

Error: Cannot find module 'ajv/dist/compile/codegen'
Require stack:
- /Users/kennethwarren/Desktop/wmfg/node_modules/ajv-keywords/dist/definitions/typeof.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/ajv-keywords/dist/keywords/typeof.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/ajv-keywords/dist/keywords/index.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/ajv-keywords/dist/index.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/schema-utils/dist/validate.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/schema-utils/dist/index.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/copy-webpack-plugin/dist/index.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/@nx/webpack/src/utils/create-copy-plugin.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/@nx/webpack/src/utils/with-nx.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/@nx/webpack/src/executors/webpack/lib/get-webpack-config.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/@nx/webpack/src/executors/webpack/webpack.impl.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/nx/src/config/workspaces.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/nx/src/command-line/run.js
- /Users/kennethwarren/Desktop/wmfg/node_modules/nx/bin/run-executor.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/kennethwarren/Desktop/wmfg/node_modules/ajv-keywords/dist/definitions/typeof.js:3:19)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)


 >  NX   Running target serve for project express failed

@huulai
Copy link

huulai commented May 6, 2023

@lucas-labs
I have the same issue. I tried downgrading all versions to 16.0.3 and it worked.
#16834 (comment)

@Duccem
Copy link

Duccem commented May 7, 2023

I have the same problem serving nestjs app
Error: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' at new NodeError (node:internal/errors:399:5) at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1059:11) at defaultResolve (node:internal/modules/esm/resolve:1135:3) at nextResolve (node:internal/modules/esm/loader:163:28) at ESMLoader.resolve (node:internal/modules/esm/loader:838:30) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18) at ESMLoader.import (node:internal/modules/esm/loader:525:22) at importModuleDynamically (node:internal/modules/cjs/loader:1186:29) at importModuleDynamicallyWrapper (node:internal/vm/module:429:21) at importModuleDynamically (node:internal/vm:106:46)

##Nx Report
 Node   : 18.16.0

OS : win32 x64
npm : 9.5.1
Hasher : Native

nx : 16.1.1
@nx/js : 16.1.1
@nx/jest : 16.1.1
@nx/linter : 16.1.1
@nx/workspace : 16.1.1
@nx/devkit : 16.1.1
@nx/eslint-plugin : 16.1.1
@nx/nest : 16.1.1
@nx/node : 16.1.1
@nrwl/tao : 16.1.1
@nx/webpack : 16.1.1
nx-cloud : 16.0.5
typescript : 5.0.4

@AgentEnder
Copy link
Member

I'm closing this as a duplicate of #16834

@lucas-labs
Copy link
Author

Same for macOS

Seems like a different problem, you probably need to npm install

@github-actions
Copy link

github-actions bot commented Jun 8, 2023

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 Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants