Failure to install node modules within react native app in a mono repo using pnpm

Viewed 121

i'm attempting to run a react native app in a monorepo using pnpm. I added it to pnpm-workspace.yaml file defined as:

packages:
  - "apps/*"

When i attempt to run npm i or pnpm i i kept getting the error below:

> sample_project@0.0.1 prepare
> cd .. && husky install frontend/.husky

line 2: husky: command not found

I have husky defined in the root folder(within pnpm-workspace.yaml). Also i declared a .npmrc file that included node-linker=hoisted but still no luck. I also ran pnpm i within the root directory but failed to install node_modules dir within the mobile directory. Please help needed. How does one run a react native app within a monorepo with pnpm? Any help will be appreciated.

Edit I have husky defined in the root directory as:

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
cd frontend
pnpm run pre-commit

and in my package.json file:

{
  "name": "sample_project",
  "version": "0.0.1",
  "private": true,
  "workspaces": [
    "apps/*",
    "packages/*"
  ],
  "scripts": {
    "build": "turbo run build",
    "dev": "turbo run dev --parallel",
    "test": "turbo run test",
    "test:lint": "turbo run test:lint",
    "fix": "turbo run fix",
    "format": "prettier --write \"**/*.{ts,tsx,md}\"",
    "prepare": "cd .. && husky install frontend/.husky",
    "pre-commit": "turbo run fix"
  },
  "devDependencies": {
    "prettier": "latest",
    "turbo": "latest",
    "husky": "latest",
    "lint-staged": "latest"
  },
  "engines": {
    "npm": ">=7.0.0",
    "node": ">=14.0.0"
  },
  "packageManager": "pnpm@7.0.1"
}

When i run the command npm i --loglevel verbose within the mobile directory below is the following errors:

> sample_project@0.0.1 prepare
> cd .. && husky install frontend/.husky

/var/folders/r5/n6lp6wsj2c52h51xxsdgw7y00000gn/T/prepare6589946269.sh: line 2: husky: command not found
npm timing command:i Completed in 54463ms
npm verb stack Error: command failed
npm verb stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:63:27)
npm verb stack     at ChildProcess.emit (node:events:513:28)
npm verb stack     at maybeClose (node:internal/child_process:1091:16)
npm verb stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm verb pkgid ***@0.0.1
npm verb cwd /Users/***/***/***/***/***/****
npm verb Darwin 21.5.0
npm verb node v18.6.0
npm verb npm  v8.13.2
npm ERR! code 127
npm ERR! path /Users/***/***/***/***
npm ERR! command failed
npm ERR! command sh -c /var/folders/r5/n6lp6wsj2c52h51xxsdgw7y00000gn/T/prepare6589946269.sh
npm verb exit 127
npm timing npm Completed in 54564ms
npm verb code 127
0 Answers
Related