Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requiring package via variable breaks package #160

Open
zhuyifang opened this issue Jun 15, 2021 · 3 comments
Open

Requiring package via variable breaks package #160

zhuyifang opened this issue Jun 15, 2021 · 3 comments
Assignees

Comments

@zhuyifang
Copy link

zhuyifang commented Jun 15, 2021

My operating environment is as follows:
macOS 11.23
electron 13.0.1

Run the following code in the main process of electron:

const FfmpegCommand = require('fluent-ffmpeg');
import {path as ffmpegPath} from'@ffmpeg-installer/ffmpeg';
command = new FfmpegCommand({
     source: item.m3u8
   });
command.setFfmpegPath(ffmpegPath)

node reported an error: not find XXXXX
XXXX is the value of npm3Package

After testing, it is caused by the use of variables in require,
In line 35 of the file @ffmpeg-installer/ffmpeg/index.js:
packageJson = require(npm3Package);
I modified it to:
packageJson = require(''+npm3Package);
The program can run normally, so...

@SavageCore
Copy link
Owner

Which node version are you using? I can't replicate this myself.

@SavageCore SavageCore changed the title not find XXX package.json Requiring package via variable breaks package Aug 4, 2021
@SavageCore SavageCore self-assigned this Aug 4, 2021
@zhuyifang
Copy link
Author

Electron : 13.1.9

I am not using a pure nodejs environment
But in the Electron environment

import ffmpegCommand from 'fluent-ffmpeg' import {path as ffmpegPath} from '@ffmpeg-installer/ffmpeg' new ffmpegCommand({ source: filePath });

image

@zhuyifang
Copy link
Author

After I changed it to this, no error will be reported and it can run normally

if (verifyFile(npm3Binary)) {
    ffmpegPath = npm3Binary;
    packageJson = require('@ffmpeg-installer/'+platform + (os.platform() === 'win32' ? '\\' : '/') + 'package.json');
    //packageJson = require(npm3Package);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants