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

dynamico is not a function #80

Closed
ronsivan1 opened this issue Dec 2, 2019 · 9 comments
Closed

dynamico is not a function #80

ronsivan1 opened this issue Dec 2, 2019 · 9 comments

Comments

@ronsivan1
Copy link

I've started a new server according to the steps in
https://github.com/Soluto/dynamico/blob/master/server/readme.md#Storage

and got the error:

TypeError: dynamico is not a function
    at Object.<anonymous> (/Users/ronsivan/Documents/repos/dynamico-registry/index.js:6:28)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
@EladBezalel
Copy link
Contributor

First of all hi and thanks for trying out Dynamico! :)

Could you please give us some more details, what storage are you trying to initiate?

You can take a look at this codesandbox which creates a server with filesystem storage

@ronsivan1
Copy link
Author

ronsivan1 commented Dec 2, 2019

Hi :)
I am using filesystem storage, this is my index.js

const express = require('express')
const dynamicoMiddleware = require('@dynamico/express-middleware');
const { FSStorage } = require('@dynamico/fs-storage');
const PORT = process.env.PORT || 5000;

const storageProvider = new FSStorage('./components');
const dynamicoMiddleware = dynamico(storageProvider);

const app = express();
app.use('/api/components', dynamicoMiddleware(new FSStorage('./components')));
.listen(PORT, () => console.log(`Listening on ${ PORT }`))

@EladBezalel
Copy link
Contributor

Looks like there's actually no dynamico variable and you are declaring dynamicoMiddleware twice..

Try this

const express = require('express')
const dynamicoMiddleware = require('@dynamico/express-middleware');
const { FSStorage } = require('@dynamico/fs-storage');
const PORT = process.env.PORT || 5000;

const app = express();
app.use('/api/components', dynamicoMiddleware(new FSStorage('./components')));
.listen(PORT, () => console.log(`Listening on ${ PORT }`))

@ronsivan1 ronsivan1 changed the title dynamico is not a function error dynamico is not a function Dec 2, 2019
@ronsivan1
Copy link
Author

Looks like there's actually no dynamico variable and you are declaring dynamicoMiddleware twice..

Try this

const express = require('express')
const dynamicoMiddleware = require('@dynamico/express-middleware');
const { FSStorage } = require('@dynamico/fs-storage');
const PORT = process.env.PORT || 5000;

const app = express();
app.use('/api/components', dynamicoMiddleware(new FSStorage('./components')));
.listen(PORT, () => console.log(`Listening on ${ PORT }`))

Ok, also added cors packaged and used it as shown in the codesandbox registry example.
It still shows the same error
/Users/ronsivan/Documents/repos/secure-springs-95544/index.js:15 7:00:36 PM web.1 | app.use('/api/components', cors(), dynamicoMiddleware(new FSStorage('./components'))); 7:00:36 PM web.1 | ^ 7:00:36 PM web.1 | TypeError: dynamicoMiddleware is not a function 7:00:36 PM web.1 | at Object.<anonymous> (/Users/ronsivan/Documents/repos/secure-springs-95544/index.js:15:36) 7:00:36 PM web.1 | at Module._compile (internal/modules/cjs/loader.js:778:30) 7:00:36 PM web.1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) 7:00:36 PM web.1 | at Module.load (internal/modules/cjs/loader.js:653:32) 7:00:36 PM web.1 | at tryModuleLoad (internal/modules/cjs/loader.js:593:12) 7:00:36 PM web.1 | at Function.Module._load (internal/modules/cjs/loader.js:585:3) 7:00:36 PM web.1 | at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) 7:00:36 PM web.1 | at startup (internal/bootstrap/node.js:283:19) 7:00:36 PM web.1 | at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) [DONE] Killing all processes with signal SIGINT 7:00:36 PM web.1 Exited with exit code null

@EladBezalel
Copy link
Contributor

Can you please try and reproduce on codesandbox?

@eladav
Copy link
Contributor

eladav commented Dec 3, 2019

Hey @rondeveloper, Can you please try adding to the require statement a reference to the default property? like so:

const dynamicoMiddleware = require('@dynamico/express-middleware').default;

Since we're just building the code with typescript the way we export the package is not consistent with commonJS. It's a known issue and we plan to solve it in the near future.

Thanks for pointing that out. We'll open an issue and link it here.

@ronsivan1
Copy link
Author

Hey @rondeveloper, Can you please try adding to the require statement a reference to the default property? like so:

const dynamicoMiddleware = require('@dynamico/express-middleware').default;

Since we're just building the code with typescript the way we export the package is not consistent with commonJS. It's a known issue and we plan to solve it in the near future.

Thanks for pointing that out. We'll open an issue and link it here.

Thanks for helping me out with this! @EladBezalel @eladav
I attended the Duda meetup and since then I've been excited to try dynamico with the new React Native app I'm working on :)

@eladav
Copy link
Contributor

eladav commented Dec 3, 2019

Hey @rondeveloper,
We're very happy to help :)

As part of our efforts to improve the framework we want to get your feedback on the integration process. We're always happy to get feedback in the form of issues, this helps us improve the product and allows others to contribute.

Also, If you're willing to jump on a quick call to tell us about your experience with setting Dynamico up that would be very helpful.

By the way, can we close this issue?

@ronsivan1
Copy link
Author

Yes, I'm closing it, I'll be glad to give feedback when I finish the whole setup process of the client/server

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