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

npm run build: Cannot find module '/home/username/destreamer/node_modules/typescript/bin/tsc #90

Closed
happybear88 opened this issue Apr 24, 2020 · 10 comments

Comments

@happybear88
Copy link

Env
Ubuntu 16.04 on WSL Windows 10 1909
git version 2.7.4
node v14.0.0
npm 6.14.4

Steps

git clone https://github.com/snobu/destreamer
cd destreamer
npm install
npm run build

ER: success
AR: error

> destreamer@2.0.0 build /home/username/destreamer
> echo Transpiling TypeScript to JavaScript... & node node_modules/typescript/bin/tsc --listEmittedFiles

Transpiling TypeScript to JavaScript...
internal/modules/cjs/loader.js:1017
  throw err;
  ^

Error: Cannot find module '/home/username/destreamer/node_modules/typescript/bin/tsc'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1014:15)
    at Function.Module._load (internal/modules/cjs/loader.js:884:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! destreamer@2.0.0 build: `echo Transpiling TypeScript to JavaScript... & node node_modules/typescript/bin/tsc --listEmittedFiles`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the destreamer@2.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-04-24T07_10_52_463Z-debug.log

Log attached.
2020-04-24T07_10_52_463Z-debug.log

@snobu
Copy link
Owner

snobu commented Apr 24, 2020

It won't work in WSL, puppeteer can't pop up a browser window. Run it with Windows Node.js in cmd.exe or PowerShell.

@happybear88
Copy link
Author

Did I miss this in readme? If not, please consider documenting it.

@snobu
Copy link
Owner

snobu commented Apr 24, 2020

You didn't, we left it out by accident. I'll add a note for it right now. Thanks for reporting this one.

@snobu snobu closed this as completed Apr 24, 2020
@snobu
Copy link
Owner

snobu commented Apr 25, 2020

Quick update here, i've tested this on WSL2 and it does work, however you'll need an Xserver so puppeteer can launch the Linux-flavored Chromium that comes down with npm install. You may also be able to plug in a Windows Chromium-based browser (since WSL2 can still launch Windows binaries) by hooking into executablePath in destreamer.ts:

const browser = await puppeteer.launch({
        executablePath: "/mnt/c/path/to/your/chrome.exe"
        headless: false,
        args: ['--disable-dev-shm-usage']
    });

^ That i didn't test so it's still just speculation.

I did however test running an Xserver and exporting DISPLAY to it, and that works -

# For WSL1
# Start Xming on Windows
export DISPLAY=:0
./destreamer.sh -i URL_TO_VIDEO

# For WSL2
# Start Xming on Windows
export DISPLAY=$(grep nameserver /etc/resolv.conf | cut -f2 -d ' '):0
./destreamer.sh -i URL_TO_VIDEO

Xming -
https://sourceforge.net/projects/xming/

@MauroFVieira
Copy link

Just confirming that @snobu 's comment about using your Windows version of Chrome (below) does work.

const browser = await puppeteer.launch({
        executablePath: "/mnt/c/path/to/your/chrome.exe"
        headless: false,
        args: ['--disable-dev-shm-usage']
    });

The XServer solution was not working for me, as the Chromium window was not rendering any content.

The only caveat is that you need to manually close the Chrome window after a successful login, as the script will fail to do it.

@hawnzah
Copy link

hawnzah commented Oct 28, 2020

Hi, I'm trying to run destreamer on wsl2.
I changed the executablePath to my windows chrome.exe, but it is not rendering any content.

In console I get this error:

[WARNING] .token_cache not found.
Launching headless Chrome to perform the OpenID Connect dance...
[ERROR] [object Object]

Do you know what could be the problem?

@rockguy40
Copy link

Hi, I'm trying to run destreamer on wsl2.
I changed the executablePath to my windows chrome.exe, but it is not rendering any content.

In console I get this error:

[WARNING] .token_cache not found.
Launching headless Chrome to perform the OpenID Connect dance...
[ERROR] [object Object]

Do you know what could be the problem?

I have the same problem. I can't seem to make it work even with xming

@phormula
Copy link

phormula commented Nov 23, 2020

Just confirming that @snobu 's comment about using your Windows version of Chrome (below) does work.

const browser = await puppeteer.launch({
        executablePath: "/mnt/c/path/to/your/chrome.exe"
        headless: false,
        args: ['--disable-dev-shm-usage']
    });

The XServer solution was not working for me, as the Chromium window was not rendering any content.

The only caveat is that you need to manually close the Chrome window after a successful login, as the script will fail to do it.

I think you need to add a back slash
Like this

        executablePath: "\/mnt\/c\/path\/to\/your\/chrome.exe"
        headless: false,
        args: ['--disable-dev-shm-usage']
    });

@rockguy40
Copy link

rockguy40 commented Nov 23, 2020

I ended up using this tutorial on yt, works as a charm
https://www.youtube.com/watch?v=9Fx7UCsSG9g

@bogdan-calapod
Copy link

I managed to get it working with WSL2 and GWSL (from the Microsoft Store). I had to install these dependencies beforehand:

sudo apt install -y libatk-bridge2.0-dev libatk1.0-dev libnss3-dev libcups2-dev libgtk-3-dev

I'm using an Ubuntu 20.04 distro from the store. After installing GWSL so that the X server is configured, as well as the dependencies above that are required to run GTK apps, it's all working smoothly.

I can make a PR that runs these steps / suggests GWSL if WSL2 environments are detected.

Thanks for the tool, guys! It's really useful!

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

No branches or pull requests

7 participants