Closed dexploneer closed 3 years ago
fs
is a node module. The scene is running in a web worker in a browser.
If you want your scene to run in a server you should use a remote scene. Here is an example of it https://github.com/decentraland/sample-scene-server
There, on the server, you can use fs
.
thats true. and what about main elements like window? if i use this simple code
sceneDidMount() {
console.log(window);
}
i get the error 'window is not defined'
guys, i understand that the scene run in a web worker but in this webworker there isnt direct access to DOM object. If for example i install web3 following the tutorial guide
https://docs.decentraland.org/sdk-reference/blockchain-operations/
i receive this error
Uncaught Error: EventDispatcher: Unhandled "error" event at _.emit (preview.js:8) at transport.onError.transport.onError.e (preview.js:8) at Worker.e.addEventListener.e (preview.js:8) emit @ preview.js:8 transport.onError.transport.onError.e @ preview.js:8 e.addEventListener.e @ preview.js:8 Uncaught ReferenceError: window is not defined
finally the problem is this
Uncaught ReferenceError: window is not defined
We are working on fixing the docs, thanks for the feedback.
Please make sure you:
import Web3 = require("web3");
const provider = await this.getEthereumProvider();
const web3 = new Web3(provider);
And that you are using the correct web3 version:
"dependencies": {
"web3": "^0.20.6"
}
hello guys, i've started a very simple project with decentraland sdk but if i try to import a native module like 'fs' i get this error.
i see errors also with other modules but at moment i think this is the strangest. because it is a native module.
my scene.tsx code is this
my package.json
what wrong? thanks in advance