strapi / blocks-react-renderer

A React renderer for the Strapi's Blocks rich text editor
Other
107 stars 15 forks source link

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

Open petross3530mx opened 3 months ago

petross3530mx commented 3 months ago

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

EvgeniyShigartsov commented 3 months ago

same problem

dpaul20 commented 3 months ago

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!!!

StructuralRealist commented 2 months ago

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

salimdellali commented 1 month ago

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

anubahv-emt commented 1 month ago

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

Abuddabi commented 1 month ago

have the same issue in developing mode

monyiliev commented 1 month ago

Same issue while installing the package. Thanks.

anubahv-emt commented 1 month ago

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