Example node script didn't run
See original GitHub issueQuite 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:
- Created a year ago
- Reactions:3
- Comments:11 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
Hey @Andrew640 what version of Node are you running?