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

Preinstall not called before try to install and collect packages information #4914

Closed
alexander-schranz opened this issue Sep 11, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@alexander-schranz
Copy link

alexander-schranz commented Sep 11, 2023

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a79

What platform is your computer?

Darwin 21.6.0 arm64 arm

What steps can reproduce the bug?

If you are using local dependencies which are only available after calling preinstall bun will fail.

e.g.:

    "scripts": {
        "preinstall": "node ./preinstall.js",
        "postinstall": "node ./postinstall.js"
    },
    "dependencies": {
        "local-package-available-after-preinstall": "file:../some/local/path"
    }

What is the expected behavior?

First call the preinstall script before try todo the install.

What do you see instead?

bun install v1.0.0 (822a00c4)


error: MissingPackageJSON


note: error occured while resolving local-package-...
error: FileNotFound installing local-package-...

Additional information

Following works:

bun run preinstall
bun install
@mryraghi
Copy link

mryraghi commented Apr 3, 2024

Same here.

I use preinstall to populate a $VAR, which is then used in 'bunfig.toml', and it seems it is also currently not working (#4901).

@gvilums

This comment was marked as outdated.

@gvilums gvilums closed this as completed May 2, 2024
@mryraghi
Copy link

mryraghi commented May 7, 2024

It still doesn't work in 1.1.7.

# bunfig.toml
[install]
registry = "https://registry.npmjs.org"

[install.scopes]
"@company" = { url = "https://etc.amazonaws.com/npm/packages/", token = "$CODEARTIFACT_AUTH_TOKEN" }

preinstall: export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token --domain receiptor-ai --region eu-west-3 --query authorizationToken --output text)

@dylan-conway
Copy link
Collaborator

@mryraghi preinstall does not run before package installation. Instead it runs before the install script, which runs after installation. See npm/cli#2660 (comment). It looks like npm plans on addressing this in the future, most likely with more lifecycle hooks (maybe npm/rfcs#403)

@mryraghi
Copy link

mryraghi commented May 8, 2024

Gotcha—thanks for clarifying.

However, I get into this issue even when installing. Sometime it works, sometime it doesn't. It's a nightmare...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants