Open apsinghdev opened 4 days ago
I have tried
import * as Y from "yjs"
(CommonJS) andconst Y = require("yjs")"
(ES module) both the methods but getting errors. Using CommonJS, I am getting the errorCannot use import statement outside a module
, and in ES module, I am gettingrequire not defined
I wonder if you need to say type="module"
in order to use import in collaboarion.js?
<script type="module" src="./js/collaboration/collaboration.js"></script>
Just an idea, I'm not really a web developer. I found this suggestion in Mozilla's official JS documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html
The same doc also recommends the .mjs extension for modules, but I have never seen anyone use it: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#aside_%E2%80%94_.mjs_versus_.js
@walterbender made commits fixing the installation error, please have a look
Addresses: #3851
I am trying to install and setup
yjs
andy-socket.io
libraries in Music Blocks. Though I've installed the libraries using npm but I am not able to access them in thecollaboration.js
file or anywhere else.I have tried
import * as Y from "yjs"
(CommonJS) andconst Y = require("yjs")"
(ES module) both the methods but getting errors. Using CommonJS, I am getting the errorCannot use import statement outside a module
, and in ES module, I am gettingrequire not defined
Current Behavior
When I log
Console.log(Y)
, it gives menot defined
error.Expected Behavior
While if library is imported, I will get a
module
as a result ofConsole.log(Y)
If you can provide any insight to sort this issue out, It'd be really helpful.