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

TypeError: Pulse is not a constructor #38

Open
hakimscode opened this issue Jun 18, 2024 · 12 comments
Open

TypeError: Pulse is not a constructor #38

hakimscode opened this issue Jun 18, 2024 · 12 comments
Assignees

Comments

@hakimscode
Copy link

I'm trying to use Pulse (migrated from Agenda). This is my code

import Pulse from '@pulsecron/pulse';

const mongoConnectionString = process.env.MONGO_URL || "mongodb://127.0.0.1:27018/pulse";
const pulse = new Pulse({ db: { address: mongoConnectionString } });

But I got an error that says:

TypeError: Pulse is not a constructor

Can someone explain why it happen and how to fix this? thanks

@hakimscode
Copy link
Author

Well, I figured it out. It turns out there is a mistake in import script. It should import like this
import { Pulse } from '@pulsecron/pulse';

@code-xhyun code-xhyun self-assigned this Jun 18, 2024
@code-xhyun
Copy link
Contributor

code-xhyun commented Jun 18, 2024

Are you using JavaScript or Typescript?

@hakimscode
Copy link
Author

@code-xhyun I'm using Typescript

@code-xhyun
Copy link
Contributor

@hakimscode
I haven't encountered the same issue, so could you please provide me with your tsconfig file and the version of Pulse you're using?

@hakimscode
Copy link
Author

@code-xhyun Sure,

I'm using "@pulsecron/pulse": "^1.5.1"

this is my tsconfig

{
  "ts-node": {
    "esm": true,
    "experimentalSpecifierResolution": "node",
    "transpileOnly": true,
    "require": ["tsconfig-paths/register"]
  },
  "tsc-alias": {
    "resolveFullPaths": true
  },
  "compilerOptions": {
    "target": "ES2020",                                  
    "experimentalDecorators": true,                   
    "emitDecoratorMetadata": true,                    
    "module": "ESNext",                                
    "rootDir": "./src",                                  
    "moduleResolution": "Node",                     
    "baseUrl": ".",                                  
    "paths": {
      "@/*": ["./src/*"]
    },                                      
    "rootDirs": ["src"],                                   
    "typeRoots": ["node_modules/@types"],                             
    "types": ["node"],                                      
    "outDir": "./dist",                                   
    "esModuleInterop": true,                             
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  },
  "include": [ "src/**/*" ],
  "exclude": ["node_modules", "dist"]
}

@code-xhyun
Copy link
Contributor

Thx : ) @hakimscode
I will solve these and give you an answer as soon as possible.

@code-xhyun
Copy link
Contributor

@hakimscode I tried the same configuration as you, but I did not encounter any issues. I will continue to investigate

image

@AlexeyMoiseev
Copy link

The same error for javascript.

@virendrak-dev
Copy link

I am using like this and getting same error

const { Pulse } = require('@pulsecron/pulse');
const pulse = new Pulse();

@code-xhyun
Copy link
Contributor

@AlexeyMoiseev @virendrak-dev I will check and inform you assuming that an issue occurs in JavaScript.

@AlexeyMoiseev
Copy link

import { Pulse } from '@pulsecron/pulse';
const pulse = new Pulse();

This works in my case. ESM, nodejs v20.15.1

@code-xhyun code-xhyun added help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Aug 10, 2024
@aryomuzakki
Copy link

I am using like this and getting same error

const { Pulse } = require('@pulsecron/pulse');
const pulse = new Pulse();

in my case this works

while const Pulse = require('@pulsecron/pulse'); throw Pulse is not a constructor

@pulsecron/pulse: 1.6.3
node 20.10.0

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

5 participants