-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
deno import Plotly error: Cannot read properties of undefined (reading 'navigator') #21871
Comments
Is this library designed to work in server side runtimes? I get the following in Node.js: > cat package.json
{
"name": "scratch",
"version": "1.0.0",
"type": "module",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"plotly.js-dist": "^2.28.0"
}
}
> cat main.js
import Plotly from "plotly.js-dist";
console.log(Plotly);
> node main.js
V:\scratch\node_modules\plotly.js-dist\plotly.js:16
})(self, function() {
^
ReferenceError: self is not defined
at Object.<anonymous> (V:\scratch\node_modules\plotly.js-dist\plotly.js:16:4)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async loadESM (node:internal/process/esm_loader:91:5)
Node.js v18.12.1 Looking at the source of that error above, it seems to be because |
Indeed, it is so: |
@gplanansky so it looks like the |
@dsherret what is the import invocation that succeeded for you in Deno? Is it the one to also use with the deno kernel in Jupyter Lab? |
@gplanansky I didn't test it further, but based on those node.js instructions this worked for me: // import Plotly from "npm:plotly.js-dist";
import Plotly from "npm:plotly";
console.log(Plotly); |
I confirm that "npm:plotly" does import in Deno. However, for plotting with the deno kernel in Jupyter Lab, as you all ably do with d3 (https://deno.com/blog/v1.37 ) and Kelly further does with vega-lite (https://blog.jupyter.org/bringing-modern-javascript-to-the-jupyter-notebook-fc998095081e), would take the web plotly. Unfortunately I guess the plotly.js-dist formulation defeats doing that. |
For reading this afterwards, the |
Version: Deno 1.39.2
GIT_COMMIT_HASH=741afc4b94427588c628925fef464623d373430f
MacOS m1
Reproduce Build deno foir aarch64-apple-darwin:
Test deno imports portals ok, fails to import plotly:
$ target/debug/deno
Deno 1.39.2
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run
deno repl
with allow flags.The text was updated successfully, but these errors were encountered: