Preinstall script fails with error "cannot run in wd"
I'm trying to convert a nuxt project from static generation to use the vercel builder. It has a 'preinstall' script in package.json which enables us to access private Git repositories for some package. This pre-existing preinstall script works fine with vercel + config to run "nuxt generate". However, when I switch the repo over to this builder I get the following
18:57:45.954 | Installing build runtime...
-- | --
18:57:48.615 | Build runtime installed: 2660.731ms
18:57:49.071 | Looking up build cache...
18:57:49.112 | Build cache not found
18:57:49.563 | ----------------- Prepare build -----------------
18:57:49.563 | Downloading files...
18:57:49.702 | Working directory: /vercel/44107ff4
18:57:49.706 | Using npm
18:57:49.707 | ℹ Prepare build took: 143.598129 ms
18:57:49.707 | ----------------- Install devDependencies -----------------
18:57:49.708 | Running npm install
18:57:50.135 | npm WARN lifecycle PACKAGE@VERSION~preinstall: cannot run in wd PACKAGE@VERSION [ -z ${GITHUB_AUTH} ] \|\| git config --global url."https://${GITHUB_AUTH}github.com/repo".InsteadOf 'ssh://[email protected]/repo
I don't understand why this is working fine generally but fails to run with this builder. How is npm install executed differently compared to the regular vercel build? Any ideas on how to fix this?
@fago Does using yarn make a difference? Search results for this error often point to permissions failures - is there anything that preinstall script is trying to do that might not be allowed in a serverless environment?
It's running this command as visible in the output above:
[ -z ${GITHUB_AUTH} ] || git config --global url."https://${GITHUB_AUTH}github.com/repo".InsteadOf 'ssh://[email protected]/rep
It's clearly that command creating troubles. But what's weird about it is that it works with the regular vercel build, where we build the site statically. I guess it's just vercel handling serverless builds differently? Is there any sort of control about this at the builder side or is that all up to vercel?
@fago We're using this helper function from Vercel: https://github.com/vercel/vercel/blob/e2db7c77347fe7698a76df8f31062b9c3b1490b4/packages/now-build-utils/src/fs/run-user-scripts.ts#L262-L301
Does that help illuminate the issue at all for you?