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

Mime.types dev server error #2

Open
tim-wise opened this issue Jun 14, 2023 · 2 comments
Open

Mime.types dev server error #2

tim-wise opened this issue Jun 14, 2023 · 2 comments

Comments

@tim-wise
Copy link

tim-wise commented Jun 14, 2023

This one might be my configuration, but I'm getting a 500 error when using the test-server.

It complains of a missing mime.types file.

{"msg":"Internal server error: ENOENT: no such file or directory, open '.../dev/digital-ocean/functions/fn-namespace/build/packages/erate/types/mime.types'"}

I deployed it to test directly on DO and see if I got more details and got the following error. Unsure if related.

2023-06-14T00:31:55.708414004Z stdout: ReferenceError: module is not defined in ES module scope
2023-06-14T00:31:55.708417622Z stdout:     at file:///tmp/index.mjs:14:53796
2023-06-14T00:31:55.708434901Z stdout:     at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

My tsconfig is below.

{
  "compilerOptions": {

    /* Language and Environment */
    "target": "ES2021",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library 

    /* Modules */
    "module": "ES2022",                                /* Specify what module code is generated. */
    "moduleResolution": "node16",                     /* Specify how TypeScript looks up a file from a given module specifier. */

    /* JavaScript Support */
    "allowJs": true,                                  /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
    "checkJs": true,                                  /* Enable error reporting in type-checked JavaScript files. */

    /* Emit */
    "sourceMap": true,                                /* Create source map files for emitted JavaScript files. */

    /* Interop Constraints */
    "verbatimModuleSyntax": true,                     /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
    // "allowSyntheticDefaultImports": true,             /* Allow 'import x from y' when a module doesn't have a default export. */
    "esModuleInterop": true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
    // "preserveSymlinks": true,                         /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
    "forceConsistentCasingInFileNames": true,            /* Ensure that casing is correct in imports. */

    /* Type Checking */
    "strict": true,                                      /* Enable all strict type-checking options. */
    "noImplicitAny": true,                            /* Enable error reporting for expressions and declarations with an implied 'any' type. */
    "strictNullChecks": true,                         /* When type checking, take into account 'null' and 'undefined'. */
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "**/*.ts"
  ]
}
@mrbrianevans
Copy link
Owner

Hi Tim, thanks for the report.
I'll need a few more details to diagnose your problem, I'm happy to work with you to get this fixed.
This is not an error I've come across before, and I don't think its being generated by the do-functions-server package.

  1. Are you using commonjs or es modules (is there a "type": "module" in your package.json file)?
  2. the digital ocean error module is not defined in ES module scope can be caused by using commonjs syntax in an es module environment (eg using modules.exports rather than export). Which export syntax are you using in your code?
  3. If you don't know where the mime.types file comes from, it may be from a 3rd party package. Which packages are you using? (a package.json might be useful for me to see)
  4. the 500 error indicates than an uncaught error has been thrown in your function logic, rather than this package throwing an error

Please provide me with some of the above details, and I'll try to help you get it working.
Thanks, Brian

@tim-wise
Copy link
Author

Sorry, my scope expanded and I'm moving to a different platform for my project, so don't worry on my account.

  1. Yes, "type": "module" is in the package.json.
  2. Nary a modules.export in any of my files.
"license": "ISC",
"author": "Tim Wise",
"type": "module",
"main": "index.js",
"scripts": {
  "build": "do-functions ./packages ./build",
  "serve": "do-functions-server ./build",
  "test": "node test.js"
},
"dependencies": {
  "do-functions": "^1.2.1",
  "do-functions-server": "^1.4.0",
  "http-status-codes": "^2.2.0",
  "quickbase": "^5.0.22",
  "soda-js": "^0.2.3"
},
"devDependencies": {
  "@types/http-status-codes": "^1.2.0",
  "@types/node": "^20.3.1",
  "dotenv": "^16.0.3",
  "typescript": "^5.1.3"
}
  1. Very likely. : )

Good luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants