Ask coding questions

← Back to all posts
TypeError: repl.User is not a constructor
h
ch1ck3n (2063)

im using rayahn's replit api and did one of the samples code and I got an error:

TypeError: repl.User is not a constructor
    at /home/runner/yo-how-many-cycles-does-coder100-relly-need-to-crash-replit/index.js:3:16
    at Script.runInContext (vm.js:130:18)
    at Object.<anonymous> (/run_dir/interp.js:209:20)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47Hint: hit control+c anytime to enter REPL.
 

any help? I'm new to nodejs

Answered by Coder100 (18177) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (18177)

you forgot to make an api

const repl = require('replapi-it');
const replapi = ReplAPI({
  username: 'ch1ck3n'
});
const myUser = new replapi.User("Coder100");
Coder100 (18177)

right
you forgot to import it
so rename to
repl.ReplAPI @ch1ck3n

Coder100 (18177)

oh i see

const replapi = repl.default.ReplAPI ...

@ch1ck3n

ch1ck3n (2063)

@Coder100 tried that already

same error

can this might be the question even the cookie can't answer??? :O

Coder100 (18177)

oh right
repl.default ffffff @ch1ck3n

ch1ck3n (2063)

@Coder100 the cookie does it again

Coder100 (18177)

i forgot ray assumed we would use mjs :barf: @ch1ck3n

Coder100 (18177)

well
get the lib docs lol