How to Download a File in NodeJS without any Third Party Libraries

If you need to download a file in NodeJS without using any third party libraries, then you can do the following. The NodeJS ecosystem comes with a fs module, this is to denote the FileSystem built in library. First declare your imports: const http = require('https'); const fs = require('fs'); Now you can use the https module to download a file, and write it to a stream using fs. const https = require("https"); const fs = require("fs"); const endpoint = "https://example/files/some_csv_file"; https....

October 26, 2022 · 1 min · 94 words · Andrew

How to Execute a Shell Script in NodeJS

If you need to execute a shell script in NodeJS, then you can use the exec keyword. Syntax: exec(command [, options] [, callback] const shell = require('shelljs') shell.exec("npm --version")

October 25, 2022 · 1 min · 29 words · Andrew

How to Uninstall npm packages

We typically install an npm package as follows: npm install <package_name> But how do we uninstall an npm package? How to uninstall an npm package This will uninstall an npm package that was installed in your project. Just make sure to run the command from the root directory of your project. npm uninstall <package_name> This will remove the package from the node_modules directory and will also remove the reference to it from the package....

June 9, 2022 · 3 min · 503 words · Andrew

[Solved] npm ERR! could not determine executable to run

If you get the following message, then there’s a very easy fix: npm ERR! could not determine executable to run The solution – using npm rm -rf .git/hooks npm install The solution – using yarn rm -rf .git/hooks yarn install

May 21, 2022 · 1 min · 40 words · Andrew

[Solved] npm ERR! path node_modules/node-sass

If you get the following error and need a solution, then look no further! npm ERR! code 1 npm ERR! path ./node_modules/node-sass npm ERR! command failed npm ERR! command sh -c node scripts/build.js npm ERR! gyp verb cli './node_modules/node-gyp/bin/node-gyp.js', npm ERR! gyp verb cli 'rebuild', npm ERR! gyp verb cli '--verbose', Option 1 – With npm First, remove the node-sass dependency from your package.json, then: npm install npm i sass npm start Option 2 – With yarn First, remove the node-sass dependency from your package....

May 20, 2022 · 1 min · 93 words · Andrew

[Solved] FirebaseError: Missing or insufficient permissions

Using Firebase and get the following error in the console? Uncaught Error in onSnapshot: FirebaseError: Missing or insufficient permissions.<br>at new FirestoreError (index.cjs.js:x) How to fix the Missing or Insufficient Permissions Error Option 1: Change rules (Recommended) Login to Firebase Go to Database -> Rules Change: service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if false; } } } to: service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if request....

December 10, 2021 · 1 min · 119 words · Andrew

[Solved] Error: Cannot find module ‘../lib/cli.js’

If you try and run npm i and get Error: Cannot find module '../lib/cli.js', then you can easily fix the problem by running the following. How does the error look? Error: Cannot find module '../lib/cli.js' Require stack: - /usr/local/lib/node_modules/npm/bin/npm-cli.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:999:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:1) at Module._compile (node:internal/modules/cjs/loader:1095:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10) at Module.load (node:internal/modules/cjs/loader:975:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/usr/local/lib/node_modules/npm/bin/npm-cli....

December 9, 2021 · 1 min · 120 words · Andrew

[Solved] Permission denied @ apply2files – /usr/local/lib/node_modules/expo-cli/node_modules/extglob/lib

If you have recently upgraded your MacOS operating system, you may get the following error in your terminal when installing some Homebrew packages: Error: Permission denied @ apply2files - /usr/local/lib/node_modules/expo-cli/node_modules/.bin/detect-libc How to solve the Permissions Denied problem Simply run the following command in your terminal: sudo chown -R $(whoami):admin /usr/local/* \ && sudo chmod -R g+rwx /usr/local/* Or change the user directly: sudo chown -R ${LOGNAME}:staff /usr/local/lib/node_modules

December 4, 2021 · 1 min · 67 words · Andrew

Introduction to NPM

What is NPM? NPM stands for Node Package Manager, and is the default way to extend your Node applications. There are an absolute ton of packages available to install and use immediately, making NPM wildly popular for software developers. What is Node? Node.js, or often simply just Node, is a Javascript runtime environment that allows Javascript code to be executed outside of the web browser. It first came about in 2009 when the creator (Ryan Dahl) took Google’s V8 Javascript Engine which powers its Chrome browser, and repurposed it....

February 6, 2020 · 8 min · 1588 words · Andrew