0neGal / viper

Launcher+Updater for TF|2 Northstar
https://0negal.github.io/viper
GNU General Public License v3.0
151 stars 21 forks source link

bug: Cannot install npm dependencies #144

Closed GeckoEidechse closed 2 years ago

GeckoEidechse commented 2 years ago

Describe the bug So I'm trying to play around with Viper again. As I'm on Ubuntu which ships a famously outdated version of Node, I'm trying to get a podman setup going (like Docker but without the root requirement).

However in the process I get the following error on running npm install inside the container:

npm notice 
npm notice New minor version of npm available! 8.5.5 -> 8.15.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.15.0>
npm notice Run `npm install -g npm@8.15.0` to update!
npm notice 
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: viper@1.6.1
npm ERR! Found: marked@4.0.18
npm ERR! node_modules/marked
npm ERR!   marked@"^4.0.10" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer marked@"^0.7.0" from marked-man@0.7.0
npm ERR! node_modules/marked-man
npm ERR!   marked-man@"^0.7.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-07-24T21_18_11_340Z-debug-0.log

To Reproduce Steps to reproduce the behavior:

  1. Use podman or docker
  2. Use the following Dockerfile and place it in repo root:
    FROM node:16.15.0-alpine
    WORKDIR /app
    COPY package.json /app
    RUN npm install
    COPY . /app
    ENTRYPOINT ["npx", "electron-builder", "--"]
  3. Run podman build -t viper-dev-container . in repo root
  4. Building container fails on RUN npm install

Expected behavior Building container should just work (or at least not fail on dependency install but something on my end with Dockerfile :P)

Version: bea0f483d7bbfbd0d8311ff69c1f04d4798a4bbb on main

Additional Info Full build log:

$ podman build -t viper-dev-container .
STEP 1/6: FROM node:16.15.0-alpine
STEP 2/6: WORKDIR /app
--> Using cache efd2ddd1d27c11c183ab5f7f12c7803e3f68902e5a5c26557269710f9097e25d
--> efd2ddd1d27
STEP 3/6: COPY package.json /app
--> Using cache 70354de44830d90367897f1d72d39c9c06a63f1c64528e98a8fe10f6d601a9aa
--> 70354de4483
STEP 4/6: RUN npm install
npm notice 
npm notice New minor version of npm available! 8.5.5 -> 8.15.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.15.0>
npm notice Run `npm install -g npm@8.15.0` to update!
npm notice 
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: viper@1.6.1
npm ERR! Found: marked@4.0.18
npm ERR! node_modules/marked
npm ERR!   marked@"^4.0.10" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer marked@"^0.7.0" from marked-man@0.7.0
npm ERR! node_modules/marked-man
npm ERR!   marked-man@"^0.7.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-07-24T21_25_41_432Z-debug-0.log
Error: error building at STEP "RUN npm install": error while running runtime: exit status 1
0neGal commented 2 years ago

I'll be honest, I'm not quite sure what the issue is, I'm not one to deal with containers and alike :p, but given the version difference updating may or may not fix it, so I'd try that first.

I also can't tell if you're actually asking for help or just making the issue to put it out there lol.

AnActualEmerald commented 2 years ago

@GeckoEidechse try using npm ci instead, it's specifically for containers/ci environments

GeckoEidechse commented 2 years ago

I'll be honest, I'm not quite sure what the issue is, I'm not one to deal with containers and alike :p, but given the version difference updating may or may not fix it, so I'd try that first.

I also can't tell if you're actually asking for help or just making the issue to put it out there lol.

I don't really see how container vs bare-metal should make a difference in the case of installing dependencies, so I figured this might be an issue with Viper itself ¯\_(ツ)_/¯

GeckoEidechse commented 2 years ago

@GeckoEidechse try using npm ci instead, it's specifically for containers/ci environments

Using

FROM node:18
WORKDIR /app
COPY package.json /app
RUN npm ci
COPY . /app
ENTRYPOINT ["npm", "run", "build"]

I get

$ podman build -t viper-dev-container .
STEP 1/6: FROM node:18
STEP 2/6: WORKDIR /app
--> Using cache 3a36df86b73c0415432b3067457639cd99188776ba4321a4d60b6e010dbfa231
--> 3a36df86b73
STEP 3/6: COPY package.json /app
--> Using cache ae858287eb850fabff1b642809115706576631cf1619d0c0dfd4f16595542af4
--> ae858287eb8
STEP 4/6: RUN npm ci
npm ERR! code EUSAGE
npm ERR! 
npm ERR! The `npm ci` command can only install with an existing package-lock.json or
npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm ERR! later to generate a package-lock.json file, then try again.
npm ERR! 
npm ERR! Clean install a project
npm ERR! 
npm ERR! Usage:
npm ERR! npm ci
npm ERR! 
npm ERR! Options:
npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
npm ERR! [--script-shell <script-shell>]
npm ERR! 
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR! 
npm ERR! Run "npm help ci" for more info

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-07-27T16_12_10_165Z-debug-0.log
Error: error building at STEP "RUN npm ci": error while running runtime: exit status 1
0neGal commented 2 years ago

I don't really see how container vs bare-metal should make a difference in the case of installing dependencies, so I figured this might be an issue with Viper itself ¯_(ツ)_/¯

Ah, I see, now that you say it, it seems it's also broken for me... npm i --force seems to fix this, I would assume this is some vulnerability in marked-man or just marked, I'll have a look at this soon and figure it out...

GeckoEidechse commented 2 years ago

Ah, I see, now that you say it, it seems it's also broken for me... npm i --force seems to fix this, [...]

Oh yeah, should've mentioned, I did try npm install --force which allows container build to finish. However trying to then do npm run build inside the container I then get:

$ podman run -it --rm  -v $(pwd):/app viper-dev-container:latest 

> viper@1.6.1 build
> npx electron-builder --win nsis --win portable --linux

Need to install the following packages:
  electron-builder@23.1.0
Ok to proceed? (y) y
  • electron-builder  version=23.1.0 os=5.15.0-41-generic
  • loaded configuration  file=package.json ("build" field)
  ⨯ Cannot compute electron version from installed node modules - none of the possible electron modules are installed and version ("^16.2.6") is not fixed in project.
See https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246

Again, this doesn't seem like docker/podman/container specific issue to me ^^

Dockerfile:

FROM node:18
WORKDIR /app
COPY package.json /app
RUN npm install --force
COPY . /app
ENTRYPOINT ["npm", "run", "build"]
Alystrasz commented 2 years ago

@0neGal why do we have marked-man as dependency? It hasn't been updated for 3 years (!), and I don't see it used in source code.

Removing this dependency seems to fix installation issue (tested with node versions 14.19.0, 16.16.0 and 18.7.0).

GeckoEidechse commented 2 years ago

@0neGal why do we have marked-man as dependency? It hasn't been updated for 3 years (!), and I don't see it used in source code.

Removing this dependency seems to fix installation issue (tested with node versions 14.19.0, 16.16.0 and 18.7.0).

Was that maybe the markdown library that was used before switching to one that supports GitHub-flavour markdown formatting?

Alystrasz commented 2 years ago

It's been introduced by this commit, adding man page creation: https://github.com/0neGal/viper/commit/823d34f6f41c65c7b1cb8e55bd429b9efc4f3878

0neGal commented 2 years ago

It is for converting Markdown to a Man page, and it hasn't actually been working for a while, at least last time I ran it, it had some errors, but I had it stay for the sake of having a man page, even though, to my knowledge the man page is not packaged with any of our release types.

Alystrasz commented 2 years ago

If it's unused, I'd suggest to remove it from Viper's dependencies; the alternative being reimplementing man page generation with another library (such as https://github.com/remarkjs/remark-man).

0neGal commented 2 years ago

Sorry for the late response! marked-man should now be gone, along with the man page files, as we don't really use it. Beside all this, it's a constant upkeep which is just annoying to update, especially considering --help exists and there's not much difference in information between the two.

Alystrasz commented 2 years ago

@GeckoEidechse can you retry running your container so we can close this issue? :)

GeckoEidechse commented 2 years ago

So container building works now (without needing --force on npm install)

Actually building inside container still fails but that's unrelated to this issue I guess ^^

Need to install the following packages:
  electron-builder@23.3.3
Ok to proceed? (y) y
  • electron-builder  version=23.3.3 os=5.15.0-46-generic
  • loaded configuration  file=package.json ("build" field)
  ⨯ Cannot compute electron version from installed node modules - none of the possible electron modules are installed and version ("^16.2.6") is not fixed in project.
See https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246

(Not really sure how to fix that cause I basically never used electron-builder and the linked GitHub comment does say to pass version as CLI arg but I have no idea which version Viper actually uses)

Alystrasz commented 2 years ago

Strange, both dependencies seem correctly fixed in package.json:

{
    ...

    "devDependencies": {
        "electron": "^16.0.6",
        "electron-builder": "^22.5.1"
    }
}

But please open a new issue if it bothers you :)

GeckoEidechse commented 2 years ago

Huh, so after clearing everything Electron related from my .cache folder, it seems to figure out electron version just fine. Weird but it works now also when it comes to the electron builder step, so I'm happy I guess ^^

GeckoEidechse commented 2 years ago

For reference, I used the following Dockerfile

FROM node:18
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
ENTRYPOINT ["npx", "electron-builder", "--linux", "appimage"]