node-ffmpeg-installer icon indicating copy to clipboard operation
node-ffmpeg-installer copied to clipboard

Using Webpack

Open johnlop opened this issue 4 years ago • 12 comments

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:

  • Node 10.15.0
  • NPM 6.10.3
  • Webpack 4.41.2
  • ffmpeg-installer 1.0.20
  • Windows 10 64b

Thanks.

johnlop avatar Nov 06 '19 17:11 johnlop

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

kribblo avatar Nov 07 '19 11:11 kribblo

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

johnlop avatar Nov 07 '19 20:11 johnlop

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

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

wangcheng007 avatar Dec 07 '19 07:12 wangcheng007

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

mpuz avatar Feb 20 '20 10:02 mpuz

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.

Fearycxy avatar May 19 '20 16:05 Fearycxy

@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

pereslavtsev avatar Sep 09 '20 21:09 pereslavtsev

Same problem ~~~

chenweijianGZ avatar Sep 26 '20 08:09 chenweijianGZ

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

Avngarde avatar Mar 04 '21 11:03 Avngarde

Same problem ...

tulies avatar Sep 08 '21 08:09 tulies

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"
  }
}

Bananamilk452 avatar Oct 31 '21 19:10 Bananamilk452

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?

yunxiaopw avatar Nov 19 '21 08:11 yunxiaopw

@pereslavtsev 's solution worked for me as well.

MateusRosario avatar Feb 08 '24 12:02 MateusRosario