From ab476577c5aa0d9592a04709d9d20dc82dc877de Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 8 Feb 2018 21:52:39 -0800 Subject: [PATCH] Detect when node_modules is empty and suggest running 'npm install' Fixes #13 --- src/cmd.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd.js b/src/cmd.js index 369ac8c..482dcdb 100755 --- a/src/cmd.js +++ b/src/cmd.js @@ -117,6 +117,11 @@ async function runThanks (cwd, promptToOpen) { const packageTree = await readPackageTreeAsync(rootPath) const pkgNames = packageTree.children.map(node => node.package.name) + if (pkgNames.length === 0) { + spinner.fail(chalk`{red No packages} found in the {magenta node_modules} folder. Try running {cyan npm install} first, silly! 😆`) + return + } + // Get latest registry data on each local package, since the local data does // not include the list of maintainers spinner.text = chalk`Fetching package {cyan maintainers} from {red npm}...`