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

overwriting os and cpu within cli npm install #7906

Open
2 tasks done
michaelgust opened this issue Nov 12, 2024 · 0 comments
Open
2 tasks done

overwriting os and cpu within cli npm install #7906

michaelgust opened this issue Nov 12, 2024 · 0 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@michaelgust
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

i want to install sharp as lambda layer for a system with

  • os = linux
  • cpu = arm64
  • libc = glibc

an error occured

work around
npm install --os=linux --cpu=arm64 --libc=glibc --force (no opportunity to determine os and cpu)

Expected Behavior

for specified os and cpu:

  • load node_moduls in folder sharp-layer/nodejs
  • create package-lock.json

Steps To Reproduce

  1. In this environment
  • Visual Studio Code
  1. With this config
  • package.json
    {
    "name": "sharp-layer",
    "version": "1.0.0",
    "main": "index.js",
    "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "description": "",
    "dependencies": {
    "@img/sharp-libvips-linux-x64": "^1.0.4",
    "@img/sharp-linux-x64": "^0.33.5",
    "sharp": "^0.33.5"
    }
    }

  • /opt/homebrew/lib/node_modules/npm/node_modules/npm-install-checks/lib/index.js
    ...
    const checkPlatform = (target, force = false, environment = {}) => {
    if (force) {
    return
    }

    const os = environment.os || currentEnv.os()
    const cpu = environment.cpu || currentEnv.cpu()
    const libc = environment.libc || currentEnv.libc(os)

    const osOk = target.os ? checkList(os, target.os) : true
    const cpuOk = target.cpu ? checkList(cpu, target.cpu) : true
    let libcOk = target.libc ? checkList(libc, target.libc) : true
    if (target.libc && !libc) {
    libcOk = false
    }

    if (!osOk || !cpuOk || !libcOk) {
    throw Object.assign(new Error('Unsupported platform'), {
    pkgid: target._id,
    current: {
    os,
    cpu,
    libc,
    },
    required: {
    os: target.os,
    cpu: target.cpu,
    libc: target.libc,
    },
    code: 'EBADPLATFORM',
    })
    }
    }
    ...

  1. Run in /sharp-layer/nodejs

npm install --os=linux --cpu=arm64 --libc=glibc

  1. See error

(node:54817) ExperimentalWarning: CommonJS module /opt/homebrew/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /opt/homebrew/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)
npm error code EBADPLATFORM
npm error notsup Unsupported platform for @img/[email protected]: wanted {"os":"linux","cpu":"x64","libc":"glibc"} (current: {"os":"darwin","cpu":"arm64"})
npm error notsup Valid os: linux
npm error notsup Actual os: darwin
npm error notsup Valid cpu: x64
npm error notsup Actual cpu: arm64
npm error notsup Valid libc: glibc
npm error notsup Actual libc: undefined
npm error A complete log of this run can be found in: /Users/mgust/.npm/_logs/2024-11-12T12_58_40_495Z-debug-0.log

Environment

  • npm: 10.9.0
  • Node.js: 23.1.0
  • OS Name: MacOS
  • System Model Name: Macbook Pro
  • npm config:
@michaelgust michaelgust added Bug thing that needs fixing Needs Triage needs review for next steps labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

1 participant