We have a game to do, but the back is already done with Graphql. And it was necessary to connect a subscription within the play-canvas game script to listen to the websoket. I wanted to know if it is somehow possible to import a package into the ide and continue working on the scripts?
@rhomE and welcome,
You can’t use NPM modules in the PlayCanvas editor. But you can load ES6 bundled modules, here is one way to do this:
Here is an example script, where you drag your module .js asset at moduleAsset, and you need to provide a global name to reference your module.
Later in your code, after it has loaded, you can access it like this:
Here is the script:
var ModuleLoader = pc.createScript('moduleLoader');
Alternatively, you can browserify the node module you want to use via the steps:
Thank you very much for the support, I really appreciate you.
I was able to solve it by importing a CDN using the external links tool.