Skip to content

"Uncaught ReferenceError: self is not defined" when trying to import using require #272

@phelps-sg

Description

@phelps-sg

I get the error in the node repl when trying to import react-plotly using require. In the browser, the call to require('react-plotly.js') returns undefined, though I don't any exception in the console.

Welcome to Node.js v16.13.1.
Type ".help" for more information.
> const {Plot} = require('react-plotly.js');
Uncaught ReferenceError: self is not defined
    at Object.58 (/home/sphelps/tmp/test/node_modules/plotly.js/dist/plotly.js:9084:9)
    at o (/home/sphelps/tmp/test/node_modules/plotly.js/dist/plotly.js:7:631)
    at /home/sphelps/tmp/test/node_modules/plotly.js/dist/plotly.js:7:682
    at Object.503.../constants/numerical (/home/sphelps/tmp/test/node_modules/plotly.js/dist/plotly.js:128735:10)
    at o (/home/sphelps/tmp/test/node_modules/plotly.js/dist/plotly.js:7:631)
    at /home/sphelps/tmp/test/node_modules/plotly.js/dist/plotly.js:7:682
    at Object.1.../src/lib (/home/sphelps/tmp/test/node_modules/plotly.js/dist/plotly.js:10:11)
    at o (/home/sphelps/tmp/test/node_modules/plotly.js/dist/plotly.js:7:631)

I am using the following dependencies:

 "dependencies": {
    "plotly.js": "^2.8.3",
    "react-plotly.js": "^2.5.1"
  }

Any suggestions as to what I am doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions