You can now officially use npm packages in your front-end page code!
14 comments
To use an npm package in your page code, simply install the package via the Package Manager and import it in your page code (same way as you currently do it on the backend).
Want to learn more about the Package Manager? Read this article and check out this example.
Is there any workaround for packages which are not yet listed?
Some packages were rejected in the past as they were intended for front end. Is there some way to fast track such packages to be added now?
(In may case, at this moment, I'd love to be able to work with twilio-chat somehow...)
@Aviv Fattal thanks for your quick reply. I just submitted a request again. It's odd, I'm pretty sure I did this yesterday, might be a problem on Wix's end. Do you see it now?
Wow Wow! Good timing too.
Does that mean front-end packages such as https://www.npmjs.com/package/sharethis-reactjs which shows a share this page bar on the side.
It means that available packages as listed here can now be used in your page code and not only in the backend files.
Do note that some packages only work in the backend or in the client. Make sure that you are using the package in the appropriate place.
Is there any workaround for packages which are not yet listed? Some packages were rejected in the past as they were intended for front end. Is there some way to fast track such packages to be added now?
(In may case, at this moment, I'd love to be able to work with twilio-chat somehow...)
@plon almon I don't see a request for that specific package, please send a request and our team will address it.
@Aviv Fattal thanks for your quick reply. I just submitted a request again. It's odd, I'm pretty sure I did this yesterday, might be a problem on Wix's end. Do you see it now?
Some that don't work in the frontend (as of yesterday):
mailgun-js
request
unirest
Can you describe what doesn't work?
@Aviv Fattal
Note that no one should probably be using the mailgun-js in front end code for security reasons.
I tried using these modules to do some testing of a mail server api.
I discovered I only had to import them to break the page. To verify I had a button that only did a console log that it was clicked.
The following errors occur by merely importing the node.
mailgun-js:
Cannot find module './streams' in '/dynamic-modules/third-party-npm/9dd0378b/WC_BEGIN/iconv-lite/0.4.24/WC_END/iconv-lite/lib/index.js'
require:
There was an error in your script
Error: Cannot find module 'net'
unirest:
There was an error in your script
Error: Cannot find module 'string_decoder'
@Aviv Fattal Having the same issue using @google-cloud/speech in page code.
Error
Cannot find module 'request' in '/dynamic-modules/third-party-npm/9dd0378b/WC_BEGIN/retry-request/4.1.1/WC_END/retry-request/index.js'