question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example node script didn't run

See original GitHub issue

Quite new to node but when I ran the example script, I got this error

const db = new Surreal('http://127.0.0.1:8000/rpc');
           ^

TypeError: Surreal is not a constructor
    at Object.<anonymous> (/Users/andrewthomas/Repos/scraper-mk-2/app.js:3:12)
    at Module._compile (node:internal/modules/cjs/loader:1119:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:997:32)
    at Module._load (node:internal/modules/cjs/loader:838:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:18:47

Got it working by accessing the default explicitly like this:

const db = new Surreal.default('http://127.0.0.1:8000/rpc');

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mathe42commented, Sep 25, 2022

OK. That I did expect. (@tobiemh and that is expected) we have to change the docs + I propose we add a named export so that the following works:

const {Surreal} = require('surrealdb.js')
1reaction
tobiemhcommented, Sep 25, 2022

Hey @Andrew640 what version of Node are you running?

node -v
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't Run or Test My NodeJS script - Stack Overflow
First, execute your script with Node.js: ... It is possible you don't have node in your path... in which case I would start...
Read more >
Maybe don't globally-install that Node.js package - codeburst
A lot of executable Node scripts, like Gulp, Grunt or Knex.js require your terminal to be at the project root directory in order...
Read more >
Configuring your application's dependencies - AWS Elastic ...
When your application runs, Node.js loads the modules from this directory. For more information, see Loading from node_modules folders ...
Read more >
scripts - npm Docs
Scripts are run by passing the line as a script argument to sh . If the script exits with a code other than...
Read more >
How To Set Up a Node.js Application for Production on ...
After running the setup script from Nodesource, you can install the ... for Node modules, so you don't need to install npm separately....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found