Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

npm preinstall and postinstall scripts are not run #523

Closed
denis-sokolov opened this issue Feb 2, 2021 · 5 comments · Fixed by #854
Closed

npm preinstall and postinstall scripts are not run #523

denis-sokolov opened this issue Feb 2, 2021 · 5 comments · Fixed by #854
Assignees
Labels
init/monorepo-support type: bug code to address defects in shipped code

Comments

@denis-sokolov
Copy link

npm preinstall and postinstall scripts are not run, resulting in breaking builds that are valid outside of Netlify.

This is caused by our caching mechanism only restoring the node_modules/ directory:

restore_cwd_cache node_modules "node modules"

And then running npm install conditionally:

if install_deps package.json $NODE_VERSION $NETLIFY_CACHE_DIR/package-sha
then
echo "Installing NPM modules using NPM version $(npm --version)"
run_npm_set_temp
if npm install ${NPM_FLAGS:+"$NPM_FLAGS"}

An existing PR fixes this: #510.

@JGAntunes JGAntunes added init/monorepo-support type: bug code to address defects in shipped code labels Feb 24, 2021
kwshi added a commit to kwshi/bamba-ink that referenced this issue Mar 18, 2021
@agostbiro
Copy link

What's the status on this? I'm running into this on the focal image.

@jonsherrard
Copy link

Is it possible to add other folders to be cache in netlify.toml at all?

I haven't seen anything outside the docs though.

Currently breaks builds that use playwright because the browser images are cached outside node_modules.

@jonsherrard
Copy link

OK idea for peeps out there stuck wthith is issue: I'm just running my "postinstall" command before the npm build command in Netlify config now.

npx [my postinstalll]] && npm run build

@mwood23
Copy link

mwood23 commented Nov 19, 2021

Just got bit by this breaking our environments because patch-package wasn't run. 😬

@pimlie
Copy link

pimlie commented Oct 24, 2022

@jobala Thanks for the PR, a quick review seems to indicate this issue is only fixed for npm users but not for yarn users? Is that correct?

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
init/monorepo-support type: bug code to address defects in shipped code
Projects
None yet
7 participants