Reputation: 333
I'have installed 'fluent-ffmpeg' plugin in my project and I added it to my angular project this way
var ffmpeg = require('fluent-ffmpeg')
and i also used this method import * as ffmpeg from 'fluent-ffmpeg'
I'm getting the following issues while building using ng serve
ERROR in ./node_modules/fluent-ffmpeg/index.js
Module not found: Error: Can't resolve './lib-cov/fluent-ffmpeg' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg'
ERROR in ./node_modules/fluent-ffmpeg/lib/ffprobe.js
Module not found: Error: Can't resolve 'child_process' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/utils.js
Module not found: Error: Can't resolve 'child_process' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/processor.js
Module not found: Error: Can't resolve 'child_process' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/recipes.js
Module not found: Error: Can't resolve 'fs' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/capabilities.js
Module not found: Error: Can't resolve 'fs' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/processor.js
Module not found: Error: Can't resolve 'fs' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/isexe/windows.js
Module not found: Error: Can't resolve 'fs' in '/home/projects/angular/demo/node_modules/isexe'
ERROR in ./node_modules/isexe/mode.js
Module not found: Error: Can't resolve 'fs' in '/home/projects/angular/demo/node_modules/isexe'
ERROR in ./node_modules/isexe/index.js
Module not found: Error: Can't resolve 'fs' in '/home/projects/angular/demo/node_modules/isexe'
ERROR in ./node_modules/fluent-ffmpeg/lib/utils.js
Module not found: Error: Can't resolve 'os' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js
Module not found: Error: Can't resolve 'path' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/processor.js
Module not found: Error: Can't resolve 'path' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/recipes.js
Module not found: Error: Can't resolve 'path' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/capabilities.js
Module not found: Error: Can't resolve 'path' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
ERROR in ./node_modules/fluent-ffmpeg/lib/options/misc.js
Module not found: Error: Can't resolve 'path' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib/options'
ERROR in ./node_modules/which/which.js
Module not found: Error: Can't resolve 'path' in '/home/projects/angular/demo/node_modules/which'
ERROR in ./node_modules/fluent-ffmpeg/lib/recipes.js
Module not found: Error: Can't resolve 'stream' in '/home/projects/angular/demo/node_modules/fluent-ffmpeg/lib'
Please how can i resolve this error
Upvotes: 0
Views: 4001
Reputation: 428
If you want to use any library in typescript which is meant for node, then use it in this way.
declare var require: any;
var ffmpeg = require('fluent-ffmpeg');
Upvotes: 1
Reputation: 1674
fluent-ffmpeg
is a JavaScript library, so you might think you can use this in your Angular application, but it is a wrapper for making calls to a ffmpeg binary. You are not able to embed the ffmpeg binary in your client-side JavaScript application, so unfortunately this library isn't helpful for your use case.
If you want to use ffmpeg you will need to make a call to your server, and use ffmpeg on the server (perhaps using fluent-ffmpeg on the server if your server runs using Node).
You will run into a lot of JavaScript projects like this one that are very common, but are for a server-like use case, not for client browser apps.
Upvotes: 0