SavageCore / node-ffprobe-installer

Platform independent binary installer of FFprobe for node projects
https://www.npmjs.com/package/@ffprobe-installer/ffprobe
73 stars 29 forks source link

Yarn PnP support #209

Closed AnhNhan closed 1 year ago

AnhNhan commented 2 years ago

Hello,

currently this package makes fixed assumptions about the node_modules folder, which is not a given when using Yarn 2 in Plug-and-Play mode.

It would be better to use require.resolve(), e.g.

// this here
const npm3Path = path.resolve(__dirname, '..', target);

// becomes this
const npm3Path = require.resolve('@ffprobe-installer/' + target + '/' + binary)

// example
require.resolve('@ffprobe-installer/win32-x64/ffprobe.exe')

// returns
const result = 'C:\\Users\\user\\dev\\project\\.yarn\\unplugged\\@ffprobe-installer-win32-x64-npm-5.0.0-6664c83f60\\node_modules\\@ffprobe-installer\\win32-x64\\ffprobe.exe';
milkcoke commented 2 years ago

I'm also waiting this issue is resolved.

SavageCore commented 1 year ago

I myself don't use Yarn PnP but happy to receive a full PR also covering npm2Path (if needed)