Setting up Node.js on Mac - node.js

I am trying to work with node.js on Mac. It was working fine. But i required to set up proxy commands like this.
npm config set registry https://registry.nomjs.org
npm config set proxy http://userid:pwd#proxy.***.com:8080
npm config se https-proxy http://userid:pwd#proxy.***.com:8080
When i tried these, i am getting these errors.
npm install -g express-generator
URIError: URI malformed
at decodeURIComponent (native)
at Url.parse (url.js:275:19)
at Object.urlParse [as parse] (url.js:81:5)
at Object.validateUrl [as validate] (/usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:164:13)
at validate (/usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:213:24)
at validate (/usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:179:11)
at /usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:101:12
at Array.map (native)
at /usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:67:15
at Array.forEach (native)
/usr/local/lib/node_modules/npm/lib/npm.js:39
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.get (/usr/local/lib/node_modules/npm/lib/npm.js:39:13)
at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:60:40)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:180:3)
at emitOne (events.js:96:13)
at process.emit (events.js:188:7)
at processEmit (/usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js:146:32)
at processEmit [as emit] (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js:146:32)
at process._fatalException (bootstrap_node.js:296:26)
-Mac-mini:~ mobilitycoehybridmacmini$ npm install -g express-generator
URIError: URI malformed
at decodeURIComponent (native)
at Url.parse (url.js:275:19)
at Object.urlParse [as parse] (url.js:81:5)
at Object.validateUrl [as validate] (/usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:164:13)
at validate (/usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:213:24)
at validate (/usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:179:11)
at /usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:101:12
at Array.map (native)
at /usr/local/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:67:15
at Array.forEach (native)
/usr/local/lib/node_modules/npm/lib/npm.js:39
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.get (/usr/local/lib/node_modules/npm/lib/npm.js:39:13)
at exit (/usr/local/lib/node_modules/npm/lib/utils/error- handler.js:60:40)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:180:3)
at emitOne (events.js:96:13)
at process.emit (events.js:188:7)
at processEmit (/usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js:146:32)
at processEmit [as emit] (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js:146:32)
at process._fatalException (bootstrap_node.js:296:26)
Can anyone help me in this??
I tried re-installing but it didn't work for me.

Related

npm ERR! Failed at the sv-work-from-home-skeleton#0.0.0 build:dev script

I am getting below error while trying to start a API
npm run build:dev
sv-work-from-home-skeleton#0.0.0 build:dev C:\Users\u063631\DairyForecast\dairyforecast_api
webpack --mode=development
webpack is watching the files…
C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\node_modules\mkdirp\lib\opts-arg.js:13
throw new TypeError('invalid options argument')
^
TypeError: invalid options argument
at optsArg (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\node_modules\mkdirp\lib\opts-arg.js:13:11)
at NodeOutputFileSystem.mkdirp (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\node_modules\mkdirp\index.js:11:10)
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compiler.js:494:26
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\Hook.js:154:20)
at Compiler.emitAssets (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compiler.js:491:19)
at onCompiled (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Watching.js:51:19)
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compiler.js:681:15
at eval (eval at create (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\HookCodeFactory.js:33:10), :20:1)
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\ts-loader\dist\after-compile.js:30:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\HookCodeFactory.js:33:10), :16:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\Hook.js:154:20)
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compiler.js:678:31
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\Hook.js:154:20)
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compilation.js:1423:35
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\Hook.js:154:20)
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compilation.js:1414:32
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\Hook.js:154:20)
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compilation.js:1409:36
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\Hook.js:154:20)
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compilation.js:1405:32
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\tapable\lib\Hook.js:154:20)
at Compilation.seal (C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compilation.js:1342:27)
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compiler.js:675:18
at C:\Users\u063631\DairyForecast\dairyforecast_api\node_modules\webpack\lib\Compilation.js:1261:4
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sv-work-from-home-skeleton#0.0.0 build:dev: webpack --mode=development
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sv-work-from-home-skeleton#0.0.0 build:dev 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\u063631\AppData\Roaming\npm-cache_logs\2022-11-09T13_30_11_402Z-debug.log
I also got below warning while doing npm install
npm WARN source-map-loader#4.0.0 requires a peer of webpack#^5.72.1 but none is installed. You must install peer dependencies yourself.

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 --version throws an error on Windows 7

When executing npm --version on Windows 7 x64, I get:
net.js:10
const cares = process.binding('cares_wrap');
^
Error: EFILE
at net.js:10:23
at NativeModule.compile (bootstrap_node.js:523:7)
at NativeModule.require (bootstrap_node.js:464:18)
at createWritableStdioStream (internal/process/stdio.js:155:19)
at process.getStdout [as stdout] (internal/process/stdio.js:10:14)
at module.exports (C:\Program Files\nodejs\node_modules\npm\node_modules\npm
log\node_modules\set-blocking\index.js:2:11)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules
\npmlog\log.js:11:1)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
net.js:10
const cares = process.binding('cares_wrap');
^
Error: EFILE
at net.js:10:23
at NativeModule.compile (bootstrap_node.js:523:7)
at NativeModule.require (bootstrap_node.js:464:18)
at tty.js:4:13
at NativeModule.compile (bootstrap_node.js:523:7)
at NativeModule.require (bootstrap_node.js:464:18)
at createWritableStdioStream (internal/process/stdio.js:142:19)
at process.getStdout [as stdout] (internal/process/stdio.js:10:14)
at module.exports (C:\Program Files\nodejs\node_modules\npm\node_modules\npm
log\node_modules\set-blocking\index.js:2:11)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules
\npmlog\log.js:11:1)
May this be that that computer is a Virtual Machine ? On the other hand, the node --version command give a correct output.

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