Uncaught Error: ENOENT: no such file or directory, open code example

Example 1: npm ERR! enoent ENOENT: no such file or directory, open

rm -rf node_modules
npm install
git commit package-lock.json
git push

Example 2: ENOENT, no such file or directory

Have you created a package.json file? Maybe run this command first again.

C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm init

It creates a package.json file in your folder.

Then run,

C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm install socket.io --save

The --save ensures your module is saved as a dependency in your package.json file.

Example 3: Error: ENOENT: no such file or directory, open

cloudinary.config({
  cloud_name: process.env.CLOUDINARY_NAME,
  api_key: process.env.CLOUDINARY_API_KEY,
  api_secret: process.env.CLOUDINARY_API_SECRET,
  shorten: true,
  secure: true,
  ssl_detected: true
})

const response = await cloudinary.uploader.upload(req.file.path)
console.log(response)

Example 4: cloudinary error: [Error: ENOENT: no such file or directory

const express = require("express");
const bodyParser = require('body-parser');
const router = express.Router();
const path = require('path');

require('dotenv').config();
require('../../client/src/components/handlers/cloudinary');
const cloudinary =require("cloudinary");
var multer  = require('multer');
var storage = multer.memoryStorage();
var upload = multer({ storage: storage });
var stream = require('stream');

router.put('/:id', upload.single('image'), function(req, res, next) {
    var upload_stream = cloudinary.v2.uploader.upload_stream(function(err,image) {   
        res.send(image.secure_url);
  });
  console.log(upload_stream);
  var bufferStream = new stream.PassThrough();
  bufferStream.end(req.file.buffer);
  bufferStream.pipe(upload_stream);
  })