File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -177,8 +177,10 @@ function postinstallBuild () {
177177 // dependency, we should always prune. Unfortunately, npm doesn't set
178178 // any helpful environment variables to indicate whether we're being
179179 // installed as a dependency or not. The best we can do is check whether
180- // the parent directory is `node_modules`.
181- var isDependency = path . basename ( path . dirname ( CWD ) ) === 'node_modules'
180+ // the parent directory is `node_modules` but the package can be nested
181+ // in multiple parent directories so we split apart the name of the module.
182+ var parentDirs = CWD . split ( path . sep )
183+ var isDependency = parentDirs . indexOf ( 'node_modules' ) !== - 1
182184
183185 if ( flags . onlyAsDependency && ! isDependency ) {
184186 log . info (
You can’t perform that action at this time.
0 commit comments