Category Archives: Node js

nodemon is not working in windows.nodemon -v is showing errors

nodemon is not working in windows.nodemon -v is showing the below  errors nodemon : File C:\Users\AppData\Roaming\npm\nodemon.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170 At line:1 char:1 + nodemon -v + ~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess   Fix… Read More »

Error [ERR_REQUIRE_ESM]: require() of ES Module E:\node-course\notes-app\node_modules\chalk\source\index.js from E:\node-course\app.js not supported. Instead change the require of index.js in E:\node-course\app.js to a dynamic import() which is available in all CommonJS modules. at Object. (E:\node-course\notes-app\app.js:8:15) { code: ‘ERR_REQUIRE_ESM’

Error [ERR_REQUIRE_ESM]: require() of ES Module E:\node-course\notes-app\node_modules\chalk\source\index.js from E:\node-course\app.js not supported. Instead change the require of index.js in E:\node-course\app.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (E:\node-course\notes-app\app.js:8:15) { code: ‘ERR_REQUIRE_ESM’   Solution is use lower version of chalk — npm install chalk@4.1.2

Error: ER_DBACCESS_DENIED_ERROR: Access denied for user ”@’localhost’ to database

Sometimes nodejs will throw errors like below Error: ER_DBACCESS_DENIED_ERROR: Access denied for user ”@’localhost’ to database ‘node_db’ at Handshake.Sequence._packetToError (E:\project\vasanthan\node_modules\mysql\lib\protocol\sequences\Sequence.js:52:14) at Handshake.ErrorPacket (E:\project\vasanthan\node_modules\mysql\lib\protocol\sequences\Handshake.js:130:18) at Protocol._parsePacket (E:\project\vasanthan\node_modules\mysql\lib\protocol\Protocol.js:279:23) at Parser.write (E:\project\vasanthan\node_modules\mysql\lib\protocol\Parser.js:76:12) at Protocol.write (E:\project\vasanthan\node_modules\mysql\lib\protocol\Protocol.js:39:16) at Socket. (E:\project\vasanthan\node_modules\mysql\lib\Connection.js:103:28) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) Solution:check the database user name and password.usually this… Read More »

Error: ER_BAD_DB_ERROR: Unknown database In nodejs

Usually the below error will generate because of unknown db name or database is not yet created Error: ER_BAD_DB_ERROR: Unknown database ‘node_dbs’ at Handshake.Sequence._packetToError (E:\project\vasanthan\node_modules\mysql\lib\protocol\sequences\Sequence.js:52:14) at Handshake.ErrorPacket (E:\project\vasanthan\node_modules\mysql\lib\protocol\sequences\Handshake.js:130:18) at Protocol._parsePacket (E:\project\vasanthan\node_modules\mysql\lib\protocol\Protocol.js:279:23) at Parser.write (E:\project\vasanthan\node_modules\mysql\lib\protocol\Parser.js:76:12) at Protocol.write (E:\project\vasanthan\node_modules\mysql\lib\protocol\Protocol.js:39:16) at Socket. (E:\project\vasanthan\node_modules\mysql\lib\Connection.js:103:28) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) Solution:Please check the… Read More »

Features of node js

Asynchronous and Event Driven − All APIs of Node.js library are asynchronous, that is, non-blocking. It essentially means a Node.js based server never waits for an API to return data. The server moves to the next API after calling it and a notification mechanism of Events of Node.js helps the server to get a response… Read More »

What is Node js

Node.js is a server-side platform built on Google Chrome’s JavaScript Engine (V8 Engine). Node.js was developed by Ryan Dahl in 2009 and its latest version is v0.10.36. The definition of Node.js as supplied by its official documentation is as follows − Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast and… Read More »

TypeError: “listener” argument must be a function Error in node js eventemitter

while executing the above code it is thowing error-TypeError: “listener” argument must be a function Solution:this is because of the code executing sequence.if we use emit() function at the bottom, then eventemitter.on() and other function should be above.