jakiestfu / stability-ts

DreamStudio Client written in TypeScript
156 stars 33 forks source link

generate is not a function #4

Closed anthonywong555 closed 1 year ago

anthonywong555 commented 1 year ago

When I try to use the stability-ts module in my project, I get the following error:

import { generate } from 'stability-ts';
         ^^^^^^^^
SyntaxError: Named export 'generate' not found. The requested module 'stability-ts' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'stability-ts';
const { generate } = pkg;

Ah! No problem. After all, my package.json type value is module. After changing the code to this:

import stability from 'stability-ts';
const { generate } = stability;

I get the following error:

TypeError: generate is not a function
    at file:///usr/src/app/src/index.js:23:17
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at next (/usr/src/app/node_modules/express/lib/router/route.js:144:13)
    at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:114:3)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:15
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:346:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:280:10)
    at jsonParser (/usr/src/app/node_modules/body-parser/lib/types/json.js:110:7)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)

When I console.log(stability) I get empty object. {}. I'm not sure if I'm missing anything else.

jakiestfu commented 1 year ago

I added a library entry in the webpack config, this should be fixed in version 1.2.0, let me know!

npm i stability-ts@1.2.0

jakiestfu commented 1 year ago

@anthonywong555 Did this fix your issues?

anthonywong555 commented 1 year ago

Ah yes! It did. Thank you so much!