blocks-react-renderer icon indicating copy to clipboard operation
blocks-react-renderer copied to clipboard

Production pipeline with omit-dev failed due to postinstall "husky install"

Open petross3530mx opened this issue 1 year ago • 8 comments

Hi dear contributors!

I have some problems with this line of code. https://github.com/strapi/blocks-react-renderer/blob/4c6faf1d62f5c513545e4150e1b02170660c289e/package.json#L47

The main problem happened when running typical build command ( for example in nextjs, for example in docker, some pipelines ) , for which dependencies under "dependencies" block typically is required, but devDependencies should be is not required (omit=dev) So husky is not installed for omit=dev, but docker tried to run postinstall command and pipeline failing

image

So there are a some possible solutions:

  1. Add condition to postinstall script to run husky only if it installed "scripts": { "postinstall": "if [ -d node_modules/husky ]; then husky install; fi" }

  2. Using prepare script for husky, which will be automatically called before npm publish "scripts": { "prepare": "husky install" }

  3. Install all the dependencies using npm install (without omit dev). Is not the best practice as devDependencies will be installed for builld

  4. Add husky to dependencies package json section which can be ok only as fast temporary fix

petross3530mx avatar Mar 28 '24 11:03 petross3530mx

same problem

EvgeniyShigartsov avatar Mar 28 '24 11:03 EvgeniyShigartsov

Hi dear contributors!

I have some problems with this line of code.

https://github.com/strapi/blocks-react-renderer/blob/4c6faf1d62f5c513545e4150e1b02170660c289e/package.json#L47

The main problem happened when running typical build command ( for example in nextjs, for example in docker, some pipelines ) , for which dependencies under "dependencies" block typically is required, but devDependencies should be is not required (omit=dev) So husky is not installed for omit=dev, but docker tried to run postinstall command and pipeline failing

image

So there are a some possible solutions:

  1. Add condition to postinstall script to run husky only if it installed "scripts": { "postinstall": "if [ -d node_modules/husky ]; then husky install; fi" }
  2. Using prepare script for husky, which will be automatically called before npm publish "scripts": { "prepare": "husky install" }
  3. Install all the dependencies using npm install (without omit dev). Is not the best practice as devDependencies will be installed for builld
  4. Add husky to dependencies package json section which can be ok only as fast temporary fix

you saved my life!!!

dpaul20 avatar Apr 06 '24 20:04 dpaul20

I have this problem when simply installing the package (not in a pipeline or during a build command). See #34 for steps to reproduce.

StructuralRealist avatar Apr 16 '24 11:04 StructuralRealist

I have the same issue, I had a React project where I test things out, I wanted to test this package, and upon installation I got the following error

$ npm i @strapi/blocks-react-renderer
npm ERR! code 1
npm ERR! path <some-path>\react-typescript-playground\node_modules\@strapi\blocks-react-renderer
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c husky install
npm ERR! 'husky' is not recognized as an internal or external command,
npm ERR! operable program or batch file.

npm ERR! A complete log of this run can be found in: <some-path>\AppData\Local\npm-cache\_logs\2024-05-12T13_40_31_534Z-debug-0.log

I am using Windows 10, nvm 1.1.12, node 20.11.1, npm 10.4.0

salimdellali avatar May 12 '24 13:05 salimdellali

how to resolve this ? I am stuck on this tried adding husky under dependencies

anubahv-emt avatar May 31 '24 08:05 anubahv-emt

have the same issue in developing mode

Abuddabi avatar Jun 01 '24 00:06 Abuddabi

Same issue while installing the package. Thanks.

monyiliev avatar Jun 02 '24 17:06 monyiliev

using pnpm for now instead of npm, seems to be working fine

anubahv-emt avatar Jun 03 '24 04:06 anubahv-emt