mas94uk / upnpTube

Cast from YouTube app to DLNA/UPNP renderers
GNU General Public License v3.0
26 stars 8 forks source link

Build failes with "Cannot destructure property..." #1

Closed tadly closed 8 months ago

tadly commented 1 year ago

Following the instructions I've created a Dockerfile for testing this project

FROM alpine:3.17

RUN apk add --no-cache \
    git \
    npm \
    yt-dlp

RUN mkdir -p /tmp/upnpTube \
    && cd /tmp/upnpTube \
    && npm install https://github.com/mas94uk/upnpTube \
    && npm link

ENTRYPOINT [ "upnpTube" ]

I also created a ubuntu version to make sure this isn't a alpine issue:

FROM ubuntu:rolling

RUN apt update && apt install --no-install-recommends -y \
    git \
    npm \
    yt-dlp

RUN mkdir -p /tmp/upnpTube \
    && cd /tmp/upnpTube \
    && npm install https://github.com/mas94uk/upnpTube \
    && npm link

ENTRYPOINT [ "upnpTube" ]

Sadly the build fails with the following error:

...
44 timing command:link Completed in 98ms
45 verbose stack TypeError: Cannot destructure property 'name' of '.for' as it is undefined.
45 verbose stack     at [diffTrees] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:336:20)
45 verbose stack     at Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:157:27)
45 verbose stack     at async Link.linkPkg (/usr/lib/node_modules/npm/lib/commands/link.js:146:5)
45 verbose stack     at async module.exports (/usr/lib/node_modules/npm/lib/cli.js:133:5)
46 verbose cwd /tmp/upnpTube
47 verbose Linux 5.4.0-135-generic
48 verbose node v19.3.0
49 verbose npm  v9.1.2
50 error Cannot destructure property 'name' of '.for' as it is undefined.

I've never done anything with npm or js so I'm not sure what to do here.

mas94uk commented 1 year ago

Thanks. I'm not very experienced with Docker but I'll see what I can do. What command do I need to run to make this happen please, just to get me started?

tadly commented 1 year ago

Sounds like you don't have this build issue on your side then? That's kinda weird.

Instead of npm install https://github.com/mas94uk/upnpTube I've now manually git clone'ed the repo and did it that way. This has worked.

dgalli1 commented 1 year ago

You probably also want to use npm ci instead of npm install https://betterprogramming.pub/npm-ci-vs-npm-install-which-should-you-use-in-your-node-js-projects-51e07cb71e26

tadly commented 1 year ago

Good lord. Why would I ever want to use npm install then? ':D What a mess.

Anyways. This is a working Dockerfile for anyone interested. It might not be the prettiest but for giving the project a whirl it's good enough

FROM alpine:3.17

RUN apk add --no-cache \
    git \
    npm \
    yt-dlp

RUN git clone https://github.com/mas94uk/upnpTube /tmp/upnpTube \
    && cd /tmp/upnpTube \
    && npm ci \
    && npm link

ENTRYPOINT [ "node", "/usr/local/bin/upnpTube" ]

And here's a docker-compose.yaml example:

version: '3'

services:
  upnpTube:
    container_name: upnp-tube
    image: mas94uk/upnp-tube
    network_mode: 'host'
    build:
      context: './upnpTube'  # folder containing the Dockerfile
    volumes:
      - '/etc/localtime:/etc/localtime:ro'  # I prefer doing it that way, don't judge
    restart: unless-stopped
mas94uk commented 1 year ago

Sounds like you don't have this build issue on your side then? That's kinda weird.

I don't know whether I do or not - I haven't had time to try it yet. Was asking what to do to make it happen since I'm not very familiar with creating Docker images.

Instead of npm install https://github.com/mas94uk/upnpTube I've now manually git clone'ed the repo and did it that way. This has worked.

is this a good solution or should it work the other way?

tadly commented 1 year ago

I don't know whether I do or not - I haven't had time to try it yet. Was asking what to do to make it happen since I'm not very familiar with creating Docker images.

What I meant is. You build your project locally for testing and that seems to work fine. I now suspect that if you do a npm install https://github.com/mas94uk/upnpTube and npm link on your system (without docker), you will get the same error.

I have never worked with npm or node (am a python guy) but if npm install <git repo url> is a supported feature (which it is) then that should work just like cloning the repository manually and doing it that way.

What I haven't tried is npm ci <git repo url>. Maybe that works better? No idea :)

mas94uk commented 1 year ago

I'll work through all this when I get a bit of free time, try and get it all resolved. Thanks for the input @tadly and @dgalli1 !

mas94uk commented 1 year ago

Finally got a bit of time to think about this. It seems the original problem is an npm bug (I found the issue and now can't find it again) but anyways the workaround seems OK for now.

I've added basically your Dockerfile and docker-compose.yaml, run it up on a couple of machines and it seems to work. I don't suppose @tadly you'd be kind enough to look at the instructions I've added to the README and tell me if it's sensible? Is there a better way to do it? I'm really not very familiar with Docker so I'm not sure what I've written makes sense.

Thanks!

mas94uk commented 8 months ago

It's all gone quiet. The workaround seems an OK way of doing it, so closing.