What is the best way to run npm install for nested folders (2024)

Hello @kartik,

If you want to run a single command to install npm packages in nested subfolders, you can run a script vianpmand mainpackage.jsonin your root directory. The script will visit every subdirectory and runnpm install.

Below is a.jsscript that will achieve the desired result:

var fs = require('fs')var resolve = require('path').resolvevar join = require('path').joinvar cp = require('child_process')var os = require('os')// get library pathvar lib = resolve(__dirname, '../lib/')fs.readdirSync(lib) .forEach(function (mod) { var modPath = join(lib, mod)// ensure path has package.jsonif (!fs.existsSync(join(modPath, 'package.json'))) return// npm binary based on OSvar npmCmd = os.platform().startsWith('win') ? 'npm.cmd' : 'npm'// install foldercp.spawn(npmCmd, ['i'], { env: process.env, cwd: modPath, stdio: 'inherit' })})

Note that this is an example taken from aStrongLooparticle that specifically addresses a modularnode.jsproject structure (including nested components andpackage.jsonfiles).

Hope it helps!!

Thank You!!

What is the best way to run npm install for nested folders (2024)
Top Articles
The best locations to invest in Airbnb rentals
No-Loss Hedging Strategies (Hype vs Reality) - Trading Heroes
DPhil Research - List of thesis titles
Hotels
Shoe Game Lit Svg
Avonlea Havanese
Team 1 Elite Club Invite
Ofw Pinoy Channel Su
P2P4U Net Soccer
Phenix Food Locker Weekly Ad
Kentucky Downs Entries Today
Myunlb
Best Food Near Detroit Airport
سریال رویای شیرین جوانی قسمت 338
Wisconsin Women's Volleyball Team Leaked Pictures
NHS England » Winter and H2 priorities
How To Cancel Goodnotes Subscription
Kp Nurse Scholars
Vintage Stock Edmond Ok
Cocaine Bear Showtimes Near Regal Opry Mills
How To Level Up Roc Rlcraft
Little Caesars 92Nd And Pecos
Panic! At The Disco - Spotify Top Songs
Culver's Flavor Of The Day Taylor Dr
Adt Residential Sales Representative Salary
Yisd Home Access Center
Xfinity Cup Race Today
Lovindabooty
Bra Size Calculator & Conversion Chart: Measure Bust & Convert Sizes
3 Ways to Drive Employee Engagement with Recognition Programs | UKG
Evil Dead Rise Ending Explained
Biografie - Geertjan Lassche
Pokémon Unbound Starters
3 Ways to Format a Computer - wikiHow
Used Safari Condo Alto R1723 For Sale
Poe T4 Aisling
Puerto Rico Pictures and Facts
Keeper Of The Lost Cities Series - Shannon Messenger
Case Funeral Home Obituaries
How To Upgrade Stamina In Blox Fruits
Sept Month Weather
Hireright Applicant Center Login
The Listings Project New York
Arigreyfr
Lamont Mortuary Globe Az
Quiktrip Maple And West
Lorton Transfer Station
Minterns German Shepherds
Random Warzone 2 Loadout Generator
786 Area Code -Get a Local Phone Number For Miami, Florida
Appsanywhere Mst
Land of Samurai: One Piece’s Wano Kuni Arc Explained
Latest Posts
Article information

Author: Manual Maggio

Last Updated:

Views: 5342

Rating: 4.9 / 5 (49 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Manual Maggio

Birthday: 1998-01-20

Address: 359 Kelvin Stream, Lake Eldonview, MT 33517-1242

Phone: +577037762465

Job: Product Hospitality Supervisor

Hobby: Gardening, Web surfing, Video gaming, Amateur radio, Flag Football, Reading, Table tennis

Introduction: My name is Manual Maggio, I am a thankful, tender, adventurous, delightful, fantastic, proud, graceful person who loves writing and wants to share my knowledge and understanding with you.