Add an error message if postinstall script was not run
What is the problem this feature would solve?
With pnpm, postinstall scripts of the dependencies are not run by default. So with a package.json like:
{
"name": "bun_test",
"scripts": {
"start": "bun --version"
},
"packageManager": "[email protected]",
"dependencies": {
"bun": "^1.3.1"
}
}
Running pnpm start results in the following:
$ pnpm start
> bun_test@ start ~/bun_test
> bun --version
$
No error is visible, but bun just refuses to run. Also the terminal exits with a non-error code.
Given this, it was quite hard for me to figure out what was happening. I had to dig to ./node_modules/.bin/bun to find out it runs a placeholder bun.exe file somewhere in node_modules, that has a companion README that explains that it's a placeholder that gets replaced when running the postinstall script.
What is the feature you are proposing to solve the problem?
Add a warning message or an error when running the placeholder executable. This won't solve the actual problem, but at least will make it more obvious that the postinstall script was not run.
What alternatives have you considered?
No response
Ah yeah it shouldn't be to hard to make it have a node script that just throws an error.
damn, node doesn't support files ending with .exe which makes it harder to work for windows. I'll just make it a bash script then to still work for people and then make it error for something for windows people.
@RiskyMH thank you for addressing this!
For the windows issue, I thought a possible solution is to have this done from the ./node_modules/.bin/bun script instead of the bun.exe placeholder. Might be a bit hacky, but it could check whether the file is still the placeholder, then show the warning.
If it was bun package manager it could (noting that bun itself is in default allowed), but otherwise i dont believe its possible to make it continue to work as cross platform. Like that .bin/bun is a simlink and it needs to be a proper exe anyway as otherwise windows says invalid, so my quick look arround couldn't see much sadly :(
You could create a polyglot executable that throws an error as a stub:
https://github.com/jart/cosmopolitan
I think this is more urgent now because more people will disable post install hooks because of the latest 🪱 problem 😓 . More people will disable post install hooks in their NPM setups. And enterprises will start to enforce this with company wide rules.