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

[fix] not working with typescript module #8

Open
3 tasks done
mohammadazeemwani opened this issue Jan 23, 2025 · 0 comments
Open
3 tasks done

[fix] not working with typescript module #8

mohammadazeemwani opened this issue Jan 23, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@mohammadazeemwani
Copy link

mohammadazeemwani commented Jan 23, 2025

Describe the bug

Node.js version: 23.6.0

OS version: macOS 14.6

Description: When I am running using this, I am getting this error

Worker for job "announcements" had an error {
  err: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/me/Desktop/scrapper/src/scrappers/jobs/announcements.ts
  require() of ES modules is not supported.
  require() of /Users/me/Desktop/scrapper/src/scrappers/jobs/announcements.ts from /Users/me/Desktop/scrapper/node_modules/@breejs/ts-worker/src/worker.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
  Instead change the requiring code to use import(), or remove "type": "module" from /Users/me/Desktop/scrapper/package.json.
  
      at createErrRequireEsm (/Users/me/Desktop/scrapper/node_modules/ts-node/dist-raw/node-internal-errors.js:46:15)
      at assertScriptCanLoadAsCJSImpl (/Users/me/Desktop/scrapper/node_modules/ts-node/dist-raw/node-internal-modules-cjs-loader.js:584:11)
      at Object.require.extensions.<computed> [as .ts] (/Users/me/Desktop/scrapper/node_modules/ts-node/src/index.ts:1610:5)
      at Module.load (node:internal/modules/cjs/loader:1473:32)
      at Function._load (node:internal/modules/cjs/loader:1285:12)
      at TracingChannel.traceSync (node:diagnostics_channel:322:14)
      at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
      at Module.require (node:internal/modules/cjs/loader:1495:12)
      at require (node:internal/modules/helpers:135:16)
      at Object.<anonymous> (/Users/me/Desktop/scrapper/node_modules/@breejs/ts-worker/src/worker.js:6:1) {
    code: 'ERR_REQUIRE_ESM'
  }
}
Worker for job "announcements" exited with code 1 undefined

in my code I am using it as

Bree.extend(breeTS)

const bree = new Bree({
  root: path.join(__dirname, 'jobs'),
  defaultExtension: keys.usingTypescript ? 'ts' : 'js',
  jobs: [
    'announcements'
  ]
})

NOTE:
I am using tsx to run my scrapper.ts

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
@mohammadazeemwani mohammadazeemwani added the bug Something isn't working label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant