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

postinstall script fails because it uses node (deno i --allow-scripts) #24916

Open
alexgleason opened this issue Aug 6, 2024 · 1 comment
Open
Labels
bug Something isn't working correctly install node compat

Comments

@alexgleason
Copy link
Contributor

alexgleason commented Aug 6, 2024

Version: Deno 1.45.5

I am trying to make vitepress (with a package.json) build with Deno using:

DENO_FUTURE=1 deno i --allow-scripts
deno task build

It results in this error:

Error launching 'node': No such file or directory (os error 2)
error: script 'postinstall' in 'vue-demi@0.14.7' failed with exit code 1
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

The problem is that node is used as an executable inside of the postinstall script of the package:

"postinstall": "node -e \"try{require('./scripts/postinstall.js')}catch(e){}\"",

I submitted an MR to vue-demi to skip the postinstall script if node is not found, because it not essential: vueuse/vue-demi#266

I'm not sure if that's the solution, or if we want to make it use the deno executable there. It would improve compatibility.

I was also able to work around it by using --allow-scripts=npm:esbuild to whitelist the only other package with a postinstall script, but it would be frustrating if there was a lot of other packages and no way to blacklist

@nathanwhit
Copy link
Member

nathanwhit commented Aug 6, 2024

I'm not sure if that's the solution, or if we want to make it use the deno executable there. It would improve compatibility.

Yeah this should use the deno executable. We actually do this already, it just currently falls back to node if there are flags specified. (In other words, node postinstall.js already works and runs Deno). We just need to handle the -e / —eval flag.

It’s straightforward, the only complication is that we should wrap the eval-ed code to inject a require function (and potentially node globals, though they aren’t strictly required in this particular case).

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

No branches or pull requests

3 participants