JavaScript settings. brain js - javascript

I have downloading VS Code, downloading brain.js using npm, found example but I get this error in console all the time.
Debugger listening on ws://127.0.0.1:31661/83ca1086-743d-46cf-96bc-4bb352980d2b
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
/Users/user/Downloads/using-machine-learning-to-determine-light-or-dark/js/index.js:1
(function (exports, require, module, __filename, __dirname) { const input =
document.querySelector("input")
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
at startup (internal/bootstrap/node.js:228:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)
Waiting for the debugger to disconnect...
ReferenceError: document is not defined
index.js:1
at Object.<anonymous> (/Users/user/Downloads/using-machine-learning-to-determine-light-or-dark/js/index.js:1:77)
at Module._compile (internal/modules/cjs/loader.js:675:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
at startup (internal/bootstrap/node.js:228:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)
How can I solve it?

document.querySelector("input") leads to document is not defined. The issue: You are running browser code in your console.

Related

TypeError when trying to run npm init in blank folder

I am trying to get into Discord bot making, and I have node installed, version 17.3.0.
When I try to run npm init in a blank folder on my desktop, it throws me this error:
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (C:\Users\bluep\AppData\Roaming\nvm\v14.15.4\node_modules\npm\node_modules\socks-proxy-agent\dist\agent.js:114:44)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\bluep\AppData\Roaming\nvm\v14.15.4\node_modules\npm\node_modules\socks-proxy-agent\dist\index.js:5:33)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\bluep\AppData\Roaming\nvm\v14.15.4\node_modules\npm\node_modules\make-fetch-happen\lib\agent.js:161:25)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (C:\Users\bluep\AppData\Roaming\nvm\v14.15.4\node_modules\npm\node_modules\socks-proxy-agent\dist\agent.js:114:44)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\bluep\AppData\Roaming\nvm\v14.15.4\node_modules\npm\node_modules\socks-proxy-agent\dist\index.js:5:33)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\bluep\AppData\Roaming\nvm\v14.15.4\node_modules\npm\node_modules\make-fetch-happen\lib\agent.js:161:25)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
It will throw me this error when I try to run any npm command. I have never seen any error like this before in this situation, and I haven't found any other person via google that's encountered this situation.
Any help is appreciated. I could be (probably am) overlooking something extremely simple and overthinking the f out of this.
Update:
The issue ended up being there was an old install of Node on my computer that did not properly uninstall when I tried to uninstall it. This caused all my issues. Thank you to everyone who tried to help, problem solved.
If anyone comes across this issue, the old version will be located in your nvm folder within your AppData directory.
That's a weird one. I would suggest using Node 16.13.1 LTS instead. LTS means Long Term Support. This means that it is probably more stable than that Node calls the "current" version. Also, since you are using Windows, try the installers available on Node.js' homepage instead of nvm. I've had issues with nvm in the past, though I've never tried it on Windows.

backend suddenly stopped working and threw this error "Cannot find module '../../cast/boolean'"

A day before my project was working fine the next day this showed up when I ran nodemon command:
module.js:471
throw err;
^
Error: Cannot find module '../../cast/boolean'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (h:\Backend\notecrates_backend\node_modules\mongoose\lib\schema\operators\exists.js:3:21)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
[nodemon] app crashed - waiting for file changes before starting...
I run my project on visual studio and I closed visual studio directly
while my project was running may be this caused the problem??

Node - Unexpected or invalid token in line 1, after reinstalling Windows

I have a JavaScript file that I could run just fine yesterday. I reinstalled Windows last night, reinstalled Node this morning, and I'm trying to run the same JavaScript file now, but its giving me an error.
$ node index.js
C:\Users\<user-name>\Google Drive\Projects\<blah>-coding\index.js:1
(function (exports, require, module, __filename, __dirname) {
SyntaxError: Invalid or unexpected token
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
code is Unicode and not working, just save as UTF-8, working great!

Cannot run Javascript code on Atom editor

Atom is not able to run javascript code for some reason, I have tried both packages such as atom runner and atom script with no success.
I have Node JS installed on my computer and javascript package installed on Atom, I have no idea why it does not work.
Here is the code which is returned after trying to run a javascript prompt.
C:\Users\artisan\Desktop\hi.js:1
(function (exports, require, module, __filename, __dirname) { var hi = prompt("wt");
^
ReferenceError: prompt is not defined
at Object.<anonymous> (C:\Users\artisan\Desktop\hi.js:1:72)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
prompt() is a function which is implemented by Web Browsers.
In serversided JS you can't use this function.

TypeError: undefined is not a function when clone old node modules

I tried to run a node app that I've cloned from
https://github.com/jensoleg/mongoose-timeseries
So I just cloned it and npm install and dependencies but when I ran an example file it gives this error! I've looked at the core code but I don't know what is the problem exactly.
mti.init('test', {interval: 1}); //second: Boolean, minute: Boolean
^
TypeError: undefined is not a function
at Object.<anonymous> (/Users/Kanin/Desktop/test/test.js:7:5)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

Categories

Resources