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

Cannot import local TS files in blitz console #1

Open
akash-joshi opened this issue Jul 5, 2022 · 0 comments
Open

Cannot import local TS files in blitz console #1

akash-joshi opened this issue Jul 5, 2022 · 0 comments

Comments

@akash-joshi
Copy link

What is the problem?

Unable to import local files inside of blitz console.

Paste all your error logs here:

While importing files via dynamic import

Uncaught Error: Cannot find package 'app' imported from C:\code\noble\noble\repl
Did you mean to import app/lib/dbUtils.ts?
    at new NodeError (node:internal/errors:372:5)
    at packageResolve (node:internal/modules/esm/resolve:954:9)
    at moduleResolve (node:internal/modules/esm/resolve:1003:20)
    at defaultResolve (node:internal/modules/esm/resolve:1218:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
    at ESMLoader.import (node:internal/modules/esm/loader:380:22)
    at importModuleDynamically (node:repl:503:47)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:21)
    at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14) {
  code: 'ERR_MODULE_NOT_FOUND'
}

While importing files via relative path

Uncaught:
TypeError: Unknown file extension ".ts" for C:\code\noble\noble\app\lib\dbUtils.ts
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async Promise.all (index 0)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runMicrotasks (<anonymous>)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:304:34)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:345:17)
    at new ModuleJob (node:internal/modules/esm/module_job:66:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:326:22)
    at ESMLoader.load (node:internal/modules/esm/loader:407:26)
    at defaultLoad (node:internal/modules/esm/load:21:20)
    at defaultGetFormat (node:internal/modules/esm/get_format:118:38)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:76:11)
    at new NodeError (node:internal/errors:372:5)
    at __node_internal_captureLargerStackTrace (node:internal/errors:465:5) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Paste all relevant code snippets here:

Import files via dynamic path

app = import("app/lib/dbUtils.ts")

Import files via relative path

app = import("./app/lib/dbUtils.ts")

What are detailed steps to reproduce this?

  1. Run blitz console.
  2. Paste the above code snippets to import local TS files in the console.

Run blitz -v and paste the output here:

Windows 10 | win32-x64 | Node: v16.15.1

blitz: 0.45.4 (local)

  Package manager: npm
  System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 1.93 GB / 13.86 GB
  Binaries:
    Node: 16.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  npmPackages:
    @prisma/client: 3.4.1 => 3.4.1
    blitz: 0.45.4 => 0.45.4
    prisma: 3.x => 3.14.0
    react: 18.0.0 => 18.0.0
    react-dom: 18.0.0 => 18.0.0
    typescript: ~4.6 => 4.6.4

Please include below any other applicable logs and screenshots that show your problem:

No response

@dillondotzip dillondotzip transferred this issue from blitz-js/blitz Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants