close window (node js) - node.js

I want it to end Roblox but I cant get it to work
The code I found
exec('tasklist', (err, out, code) => {
const id = processIdFromTaskList("RobloxPlayerBeta.exe", out);
process.kill(id, "SIGKILL");
});
Node = v18.13.0
The error I get:
[Error_Handling] :: Uncaught Exception/Catch (MONITOR)
ReferenceError: processIdFromTaskList is not defined
at D:\Js\Natro-macro-control-Testing\Commands\Control\close.js:15:16
at ChildProcess.exithandler (node:child_process:411:7)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5) uncaughtException
[Error_Handling] :: Uncaught Exception/Catch
ReferenceError: processIdFromTaskList is not defined
at D:\Js\Natro-macro-control-Testing\Commands\Control\close.js:15:16
at ChildProcess.exithandler (node:child_process:411:7)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5) uncaughtException

Related

Why I can't install packages with npm?

Trying simple command npm i --legacy-peer-deps and this is what i get:
1474 verbose type system
1475 verbose stack FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/#nrwl%2freact: 12620:error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:677:
1475 verbose stack
1475 verbose stack at C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\minipass-fetch\lib\body.js:168:15
1475 verbose stack at processTicksAndRejections (internal/process/task_queues.js:95:5)
1475 verbose stack at async RegistryFetcher.packument (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\registry.js:99:25)
1475 verbose stack at async RegistryFetcher.manifest (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\registry.js:124:23)
1475 verbose stack at async Arborist.[nodeFromEdge] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\bui ld-ideal-tree.js:1107:19)
1475 verbose stack at async Arborist.[buildDepStep] (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\bui ld-ideal-tree.js:976:11)
1475 verbose stack at async Arborist.buildIdealTree (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\bui ld-ideal-tree.js:218:7)
1475 verbose stack at async Promise.all (index 1)
1475 verbose stack at async Arborist.reify (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\reify.js:154:5)
1475 verbose stack at async Install.exec (C:\Users\User\AppData\Roaming\npm\node_modules\npm\lib\commands\install.js:145:5)
1476 verbose cwd D:\Samir\Projects\GO\gomango-next
1477 verbose Windows_NT 10.0.19044
1478 verbose node v14.19.3
1479 verbose npm v8.16.0
1480 error code ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
1481 error errno ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
1482 error Invalid response body while trying to fetch https://registry.npmjs.org/#nrwl%2freact: 12620:error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:677:
1482 error
1483 verbose exit 1
1484 timing npm Completed in 33810ms
1485 verbose unfinished npm timer reify 1660050096991
1486 verbose unfinished npm timer reify:loadTrees 1660050097001
1487 verbose code 1
1488 error A complete log of this run can be found in:
1488 error C:\Users\User\AppData\Local\npm-cache\_logs\2022-08-09T13_01_36_761Z-debug-0.log
node version: 14.19.3
npm version: 8.16.0
OS: Windows

mac os, after npm update I get strange errors, when I open a terminal

When I start new terminal - I see the error.
I press Enter - and then I can work normally.
Why this happens and how to fix this?
apower ~/Desktop/t1 node:events:505
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at afterWriteDispatched (node:internal/stream_base_commons:160:15)
at writeGeneric (node:internal/stream_base_commons:151:3)
at Socket._writeGeneric (node:net:823:11)
at Socket._write (node:net:835:8)
at writeOrBuffer (node:internal/streams/writable:390:12)
at _write (node:internal/streams/writable:331:10)
at Writable.write (node:internal/streams/writable:335:10)
at SafeSubscriber._next (/usr/local/lib/node_modules/#angular/cli/node_modules/#angular-devkit/core/node/cli-logger.js:52:20)
at SafeSubscriber.__tryOrUnsub (/usr/local/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Subscriber.js:205:16)
at SafeSubscriber.next (/usr/local/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Subscriber.js:143:22)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}
Node.js v18.2.0
apower ~/Desktop/t1
apower ~/Desktop/t1 npm -v
8.12.1
apower ~/Desktop/t1 node -v
v18.2.0

Laravel 8 and JetStream npm run dev error in windows

npm run dev
cmd error
[enter image description henter image description hereere]2
node:events:498
throw er; // Unhandled 'error' event
^
Error: write EIO
at afterWriteDispatched (node:internal/stream_base_commons:160:15)
at writeGeneric (node:internal/stream_base_commons:151:3)
at WriteStream.Socket._writeGeneric (node:net:795:11)
at WriteStream.Socket._write (node:net:807:8)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at WriteStream.Writable.write (node:internal/streams/writable:334:10)
at LogUpdate.write (C:\wamp64\www\hospital_app\node_modules\webpackbar\dist\index.cjs:1384:35)
at LogUpdate.render (C:\wamp64\www\hospital_app\node_modules\webpackbar\dist\index.cjs:1374:10)
at FancyReporter._renderStates (C:\wamp64\www\hospital_app\node_modules\webpackbar\dist\index.cjs:1456:15)
Emitted 'error' event on WriteStream instance at:
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -4070,
code: 'EIO',
syscall: 'write'
node and npm version are
C:\wamp64\www\hospital_app>node -v
v16.14.0
C:\wamp64\www\hospital_app>npm -v
8.3.1
pls help me to solve this ?

'npm start' gives an error and does not start the development server

I'm new to node and react and am trying to start a local development server for my react app. To start it I did npm start but this put out an error. The log looks like this:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.16.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle myapp#0.1.0~prestart: myapp#0.1.0
6 info lifecycle myapp#0.1.0~start: myapp#0.1.0
7 verbose lifecycle myapp#0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle myapp#0.1.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;E:\full-stack projects\react tutoral\myapp\node_modules\.bin;C:\Program Files\Git\mingw32\bin;C:\Program Files\Git\usr\bin;C:\Users\User\bin;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files\PostgreSQL\10\bin;C:\Program Files\PostgreSQL\10\libC;C:\Program Files\Git\Python27;C:\Python27\scripts;C:\Users\User\AppData\Local\Programs\Python\Python37-32;C:\Users\User\AppData\Local\Programs\Python\Python37-32\Scripts;C:\Program Files\nodejs;C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\heroku\bin;C:\Users\User\AppData\Roaming\npm
9 verbose lifecycle myapp#0.1.0~start: CWD: E:\full-stack projects\react tutoral\myapp
10 silly lifecycle myapp#0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle myapp#0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle myapp#0.1.0~start: Failed to exec start script
13 verbose stack Error: myapp#0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:310:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:310:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid myapp#0.1.0
15 verbose cwd E:\full-stack projects\react tutoral\myapp
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v12.16.3
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error myapp#0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the myapp#0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
How do I fix this?
EDIT
Here is the package.json for the app:
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
EDIT 2
I have tried all the solutions suggested, but it always shows the same errror. Here is how the error is shown in the termianl (bash):
events.js:287
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)←[39m
←[90m at onErrorNT (internal/child_process.js:469:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m
Emitted 'error' event on ChildProcess instance at:
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)←[39m
←[90m at onErrorNT (internal/child_process.js:469:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m {
errno: ←[32m'ENOENT'←[39m,
code: ←[32m'ENOENT'←[39m,
syscall: ←[32m'spawn cmd'←[39m,
path: ←[32m'cmd'←[39m,
spawnargs: [ ←[32m'/s'←[39m, ←[32m'/c'←[39m, ←[32m'start'←[39m, ←[32m'""'←[39m, ←[32m'/b'←[39m, ←[32m'"http://localhost:3000"'←[39m ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2020-05-07T16_48_16_197Z-debug.log
ignore this line. Stackoverflow requires me to describe the problem in details since most of this is code
Ok so this problem was with the Windows system32 variable. Its actually really easy to solve. Just add the following to the PATH variable:
C:\Windows\System32

Mongo errors when mongoose is updated from 3.8.8 to 4.x

I have a MEAN stack project.
I'm using node v5.9.1 with
"mongoose": "~3.8.8"
MongoDB shell version: 3.0.10 on Ubuntu 15.10
I need to use mongoose-encryption which says it needs mongoose 4.x.
Whenever i upgrade mongoose from 3.8 to 4.x, the server keeps crashing when a request is received.
info: MEAN.JS application started on port 3000
(node) warning: possible EventEmitter memory leak detected. 11 reconnect listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at addListener (events.js:252:17)
at Server.connect (/media/saket/d/git/project/node_modules/mongodb/lib/server.js:326:17)
at open (/media/saket/d/git/project/node_modules/mongodb/lib/db.js:224:19)
at Db.open (/media/saket/d/git/project/node_modules/mongodb/lib/db.js:247:44)
at MongoStore._open_database (/media/saket/d/git/project/node_modules/connect-mongo/lib/connect-mongo.js:182:15)
at MongoStore._get_collection (/media/saket/d/git/project/node_modules/connect-mongo/lib/connect-mongo.js:177:14)
at /media/saket/d/git/project/node_modules/connect-mongo/lib/connect-mongo.js:194:16
at /media/saket/d/git/project/node_modules/mongodb/lib/db.js:234:5
at connectHandler (/media/saket/d/git/project/node_modules/mongodb/lib/server.js:306:7)
at g (events.js:273:16)
at emitOne (events.js:90:13)
at emit (events.js:182:7)
at /media/saket/d/git/project/node_modules/mongodb-core/lib/topologies/server.js:540:23
at commandCallback (/media/saket/d/git/project/node_modules/mongodb-core/lib/topologies/server.js:1161:9)
at Callbacks.emit (/media/saket/d/git/project/node_modules/mongodb-core/lib/topologies/server.js:119:3)
at null.messageHandler (/media/saket/d/git/project/node_modules/mongodb-core/lib/topologies/server.js:295:23)
(node) warning: possible EventEmitter memory leak detected. 11 destroy listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at addListener (events.js:252:17)
at once (events.js:278:8)
at connectHandler (/media/saket/d/git/project/node_modules/mongodb/lib/server.js:281:19)
at g (events.js:273:16)
at emitOne (events.js:90:13)
at emit (events.js:182:7)
at /media/saket/d/git/project/node_modules/mongodb-core/lib/topologies/server.js:540:23
at commandCallback (/media/saket/d/git/project/node_modules/mongodb-core/lib/topologies/server.js:1161:9)
at Callbacks.emit (/media/saket/d/git/project/node_modules/mongodb-core/lib/topologies/server.js:119:3)
at null.messageHandler (/media/saket/d/git/project/node_modules/mongodb-core/lib/topologies/server.js:295:23)
at Socket.<anonymous> (/media/saket/d/git/project/node_modules/mongodb-core/lib/connection/connection.js:285:22)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at TCP.onread (net.js:529:20)
GET / - - ms - -
/media/saket/d/git/project/node_modules/mongodb/lib/server.js:242
process.nextTick(function() { throw err; })
^
MongoError: Error connecting to database: server localhost:27017 timed out
at null.<anonymous> (/media/saket/d/git/project/node_modules/mongodb-core/lib/topologies/server.js:408:40)
at emitTwo (events.js:100:13)
at emit (events.js:185:7)
at null.<anonymous> (/media/saket/d/git/project/node_modules/mongodb-core/lib/connection/pool.js:144:10)
at g (events.js:273:16)
at emitTwo (events.js:100:13)
at emit (events.js:185:7)
at Socket.<anonymous> (/media/saket/d/git/project/node_modules/mongodb-core/lib/connection/connection.js:165:12)
at Socket.g (events.js:273:16)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at TCP._onclose (net.js:475:12)
Sometimes it throws this error too:
/media/saket/d/git/project/node_modules/mongodb/lib/server.js:242
process.nextTick(function() { throw err; })
^
Error: connect EADDRNOTAVAIL 127.0.0.1:27017 - Local (127.0.0.1:0)
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at connect (net.js:847:16)
at net.js:980:7
at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:63:16)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:82:10)

Resources