inxilpro / node-app-root-path

Determine the root path to your project
MIT License
604 stars 29 forks source link

PNPM support? #38

Closed BlackDark closed 5 years ago

BlackDark commented 5 years ago

The resolution with pnpm https://github.com/pnpm/pnpm seems not to work as expected.

My setup is a nestjs project with typeorm.

The resulting app root path is under .../project/dist which is the build path of a nestjs project but not the root.

From my investigations i see the error happens here: https://github.com/inxilpro/node-app-root-path/blob/master/lib/resolve.js#L64

Because pnpm fills the global path with multiple entries like:

  '/Users/user/projects/tmp/test-orm/node_modules/.pnpm/custom.npm.registry/@nestjs/cli/6.11.0/node_modules/@nestjs/cli/bin/node_modules',
  '/Users/user/projects/tmp/test-orm/node_modules/.pnpm/custom.npm.registry/@nestjs/cli/6.11.0/node_modules/@nestjs/cli/node_modules',
  '/Users/user/projects/tmp/test-orm/node_modules/.pnpm/custom.npm.registry/@nestjs/cli/6.11.0/node_modules/@nestjs/node_modules',
  '/Users/user/projects/tmp/test-orm/node_modules/.pnpm/custom.npm.registry/@nestjs/cli/6.11.0/node_modules',
  '/Users/user/projects/tmp/test-orm/node_modules/.pnpm/custom.npm.registry/@nestjs/cli/node_modules',
  '/Users/user/projects/tmp/test-orm/node_modules/.pnpm/custom.npm.registry/@nestjs/node_modules',
  '/Users/user/projects/tmp/test-orm/node_modules/.pnpm/custom.npm.registry/node_modules',
  '/Users/user/projects/tmp/test-orm/node_modules/.pnpm/node_modules',
  '/Users/user/projects/tmp/test-orm/node_modules',

And then the check for global matches even if it is not a global thing. For my case the solutions here: https://github.com/inxilpro/node-app-root-path/blob/master/lib/resolve.js#L74 would bring the desired effect.