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

Getting TypeError: ImageKit is not a constructor after upgrade to 4.0.0 #54

Closed
ghost opened this issue Jul 2, 2022 · 4 comments
Closed

Comments

@ghost
Copy link

ghost commented Jul 2, 2022

Node version v16.15.1.
Package-lock segment:

    "node_modules/imagekit": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/imagekit/-/imagekit-4.0.0.tgz",
      "integrity": "sha512-8UFOuAQbztzM6v/U4t+okBzqeqmwYWhCa3A5dd2YpK9HYOvJQexucplTO4UA6ioynXhLzrq9nVDK0K9Y7yZRdw==",
      "dependencies": {
        "axios": "^0.27.2",
        "form-data": "^4.0.0",
        "hamming-distance": "^1.0.0",
        "lodash": "^4.17.15",
        "tslib": "^2.4.0",
        "uuid": "^8.3.2"
      },
      "engines": {
        "node": ">=10.0.0"
      }
    },
@ahnv
Copy link
Member

ahnv commented Jul 2, 2022

Can you give the following details?

Are you using typescript or javascript?
Are you importing the module using require or import? Also, send the import or require statement you are using

@ghost
Copy link
Author

ghost commented Jul 2, 2022

Hi, the code was following to preserve backward compatibility with node v14:

const ImageKit = require('imagekit');

// imagekit auth
app.get("/imagekit_auth", function(request, response) {
	const imagekit = new ImageKit(require('./config').imagekit);
	try {
		const token = request.query.token || uuid.v4();
		const expiration = request.query.expire || parseInt(Date.now()/1000)+ (60 * 10); // Default expiration in 10 mins
		const signatureObj = imagekit.getAuthenticationParameters(token, expiration);
		response.status(200).send(signatureObj);
	} catch (err) {
		console.error("Error while responding to imagekit_upload request:", JSON.stringify(err, undefined, 2));
		response.status(500).send("Internal Server Error");
	}
});

The code was taken directly from your guide.

@imagekitio
Copy link
Collaborator

Version 4.0.1 fixes it

@ohabash
Copy link

ohabash commented Apr 6, 2023

@imagekitio im using "imagekit-javascript": "^1.5.5", what should i do if i get this error?

imagekit_javascript_1.default is not a constructor

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

3 participants