Somes error m3u8stream - sax.js
Hello, I have multiple errors with use node-ytdl-core in Electron app + Angular - latest version of all :
WARNING in ./node_modules/m3u8stream/node_modules/sax/lib/sax.js Module not found: Error: Can't resolve 'stream' in '/Users/sebastiendoutre/Downloads/electronapp/my-first-project/node_modules/m3u8stream/node_modules/sax/lib'
WARNING in ./node_modules/ytdl-core/node_modules/sax/lib/sax.js Module not found: Error: Can't resolve 'stream' in '/Users/sebastiendoutre/Downloads/electronapp/my-first-project/node_modules/ytdl-core/node_modules/sax/lib'
ERROR in ./node_modules/miniget/lib/index.js Module not found: Error: Can't resolve 'http' in '/Users/sebastiendoutre/Downloads/electronapp/my-first-project/node_modules/miniget/lib' ERROR in ./node_modules/miniget/lib/index.js Module not found: Error: Can't resolve 'https' in '/Users/sebastiendoutre/Downloads/electronapp/my-first-project/node_modules/miniget/lib' ERROR in ./node_modules/m3u8stream/lib/index.js Module not found: Error: Can't resolve 'stream' in '/Users/sebastiendoutre/Downloads/electronapp/my-first-project/node_modules/m3u8stream/lib' ERROR in ./node_modules/m3u8stream/lib/m3u8-parser.js Module not found: Error: Can't resolve 'stream' in '/Users/sebastiendoutre/Downloads/electronapp/my-first-project/node_modules/m3u8stream/lib' ERROR in ./node_modules/m3u8stream/lib/dash-mpd-parser.js Module not found: Error: Can't resolve 'stream' in '/Users/sebastiendoutre/Downloads/electronapp/my-first-project/node_modules/m3u8stream/lib' ERROR in ./node_modules/miniget/lib/index.js Module not found: Error: Can't resolve 'stream' in '/Users/sebastiendoutre/Downloads/electronapp/my-first-project/node_modules/miniget/lib' ERROR in ./node_modules/ytdl-core/lib/index.js Module not found: Error: Can't resolve 'stream' in '/Users/sebastiendoutre/Downloads/electronapp/my-first-project/node_modules/ytdl-core/lib'
I searched everywhere and found nothing similar to help me solve this problem.
my package.json:
{
"name": "app",
"version": "1.0.0",
"license": "MIT",
"main": "main.js",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"clean": "rm -rf ./dist ./releases",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron": "electron .",
"electron-build": "ng build --prod && electron .",
"dist-mac": "ng build --prod && electron-packager . --overwrite --out=releases --ignore=e2e --ignore=src --platform=darwin --arch=x64"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.15",
"@angular/common": "^7.2.15",
"@angular/compiler": "^7.2.15",
"@angular/core": "^7.2.15",
"@angular/forms": "^7.2.15",
"@angular/http": "^7.2.15",
"@angular/platform-browser": "^7.2.15",
"@angular/platform-browser-dynamic": "^7.2.15",
"@angular/router": "^7.2.15",
"angular-svg-round-progressbar": "^2.0.0",
"core-js": "^3.1.0",
"dotenv": "^8.0.0",
"electron-clipboard-watcher": "^1.0.1",
"ffmpeg-static": "^2.4.0",
"fluent-ffmpeg": "^2.1.2",
"ngx-electron": "^2.1.1",
"rxjs": "^6.5.2",
"rxjs-compat": "^6.0.0-rc.0",
"tslib": "^1.9.3",
"ytdl-core": "^0.29.2",
"zone.js": "^0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "^7.3.9",
"@angular/compiler-cli": "^7.2.15",
"@angular/language-service": "^7.2.15",
"@types/jasmine": "^3.3.12",
"@types/jasminewd2": "^2.0.6",
"@types/node": "^12.0.2",
"codelyzer": "^5.0.1",
"electron": "^5.0.1",
"electron-icon-maker": "0.0.4",
"electron-packager": "^13.1.1",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "^6.0.0",
"ts-node": "~8.1.0",
"tslint": "~5.16.0",
"typescript": "3.2.4"
}
}
In main.js component:
import { Component, OnInit, Injectable, NgZone } from '@angular/core';
import { ElectronService } from 'ngx-electron';
import * as ytdl from 'ytdl-core';
getInfo(url){
let promise = new Promise((resolve, reject) => {
Ytdl.getInfo(this.url, (err, info) => {
if(err) reject(err);
resolve(info);
});
})
.then((data) => {
this.loaded = true;
this.info = data
});
return promise;
}
Thanks all
Hello, I resolve a part of the issue but I have always a problem with 'http' and 'https'.
In index.js
const request = require('miniget');
const m3u8stream = require('m3u8stream');
const parseTime = require('m3u8stream/lib/parse-time');
and in miniget
const http = require('http');
const https = require('https');
But if I use npm install httpand npm install httpsit does not work.
npm ls http └── [email protected]
npm ls https └── [email protected]
Thanks for your help.
I solved the problem. It's because node library can not be called from an Angular page in an application with Electron. Passing from the main.js file with require ('ytdl-core') it works again