kribblo / node-ffmpeg-installer

Platform independent binary installer of FFmpeg for node projects
https://www.npmjs.com/package/@ffmpeg-installer/ffmpeg
422 stars 70 forks source link

Using Webpack #39

Open johnlop opened 5 years ago

johnlop commented 5 years ago

Hi, I'm adding Webpack to my NodeJS project but having issues with ffmpeg-installer. The build process works but when running the app I get the following error:

Cannot find module "[...]\@ffmpeg-installer\win32-x64\package.json"

Not sure what to do to fix this but anyway I'm curious if anyone else has used Webpack with this package.

Info:

Thanks.

kribblo commented 5 years ago

I've only ever used browserify, so not sure about this. If you look in your node_modules directory, is the file available there?

johnlop commented 5 years ago

Yeah the file is there and the other modules seem ok.

wangcheng007 commented 4 years ago

Yeah the file is there and the other modules seem ok.

hi,I met the same problem. Have you solved it?

mpuz commented 4 years ago

Same problem - Error: Cannot find module 'C:\Users\user\Documents\PROJECTS\....\node_modules\@ffmpeg-installer\win32-x64\package.json'

Fearycxy commented 4 years ago

Same problem: Cannot find module '....../node_modules/@ffmpeg-installer/darwin-x64/package.json' in vue project and I tried yard remove and reinstall, doesn't work.

pereslavtsev commented 4 years ago

@johnlop with nodejs you can try to use something like this:

module.exports = {
  // ...some configs
  target: 'node',
  plugins: [
    new webpack.EnvironmentPlugin({
      FLUENTFFMPEG_COV: false,
    }),
  ],
  output: {
    libraryTarget: 'commonjs',
  },
  externals: [
    nodeExternals(),
    { '@ffmpeg-installer/ffmpeg': { commonjs: '@ffmpeg-installer/ffmpeg' } },
    { 'fluent-ffmpeg': { commonjs: 'fluent-ffmpeg' } },
  ],
}

but it can works if you use a webpack-node-externals - I don't know how to solve the issue without that

chenweijianGZ commented 4 years ago

Same problem ~~~

Avngarde commented 3 years ago

@pereslavtsev Your solution worked for me. Using electron + webpack. Thanks!

tulies commented 3 years ago

Same problem ...

Bananamilk452 commented 3 years ago

i used this solution because some dependencies are using es6 export. (i'm using vue with electron-builder. not sure it works with plain webpack) simillar with answer on above;

// webpack.config.js
module.exports = {
  // ...
  externals: [
    nodeExternals({
      modulesFromFile: {
        fileName: './package.json',
        includeInBundle: ['devDependencies', 'dependencies'],
        excludeFromBundle: ['excludeFromBundle'],
      },
    }),
  ],
}
// package.json
{
  // some configs
  // you dont have to remove this packages from dependencies
  "excludeFromBundle": {
    "@ffmpeg-installer/ffmpeg": "^1.1.0",
    "fluent-ffmpeg": "^2.1.2"
  }
}
yunxiaopw commented 2 years ago

Same problem - Error: Cannot find module 'C:\Users\user\Documents\PROJECTS\....\node_modules\@ffmpeg-installer\win32-x64\package.json'

Hello, have you solved this problem? How to solve it?

MateusRosario commented 9 months ago

@pereslavtsev 's solution worked for me as well.