- Notifications
You must be signed in to change notification settings - Fork 220
Description
Description
Hi! I'm seeing the following error when running bob build
:
Failed to locate 'tsc' in the workspace. Falling back to the globally installed version. Consider adding typescript to your devDependencies or specifying the tsc option for the typescript target.
I think this is only an issue when using npm
or pnpm
instead of yarn
. In my case I don't have a choice because I'm working in a pnpm
monorepo 😄
I looked at the code and in lib/targets/typescript.js
, it attempts to run npm bin
to get the path to the bin
folder.
When I log the response of this, it appears that the npm bin
command doesn't exist. I'm on npm v9.5.1.
I can't find any release notes around npm bin
being removed, but strangely I don't see it in their docs anywhere for v9. It seems to have just disappeared after v8: https://docs.npmjs.com/cli/v9/commands.
For anyone else that runs into this: a workaround is to explicitly add the path to the tsc
command in the targets
config:
"react-native-builder-bob": { "source": "src", "output": "lib", "targets": [ "commonjs", "module", [ "typescript", { "project": "tsconfig.json", "tsc": "./node_modules/.bin/tsc" // here!! } ] ] },
You can reproduce this with a pretty standard setup:
- Run
npx create-react-native-library@latest some-cool-name
- Select
JavaScript library
- Run
yarn
ornpm install
in the generated project (which one you run doesn't seem to matter) - Run
npm run prepack
Packages
- create-react-native-library
- react-native-builder-bob
Selected options
Basic configuration via npx create-react-native-library@latest
. Selected Javascript Library
. Nothing else changed
Link to repro
No response
Environment
System: OS: macOS 12.6.8 CPU: (10) arm64 Apple M1 Pro Memory: 108.08 MB / 32.00 GB Shell: version: 5.8.1 path: /bin/zsh Binaries: Node: version: 18.16.0 path: ~/.nvm/versions/node/v18.16.0/bin/node Yarn: version: 1.22.19 path: ~/.nvm/versions/node/v18.16.0/bin/yarn npm: version: 9.5.1 path: ~/.nvm/versions/node/v18.16.0/bin/npm Watchman: version: 2023.05.22.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.12.1 path: /Users/jon.rigert/.rbenv/shims/pod SDKs: iOS SDK: Platforms: - DriverKit 22.1 - iOS 16.1 - macOS 13.0 - tvOS 16.1 - watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8815526 Xcode: version: 14.1/14B47b path: /usr/bin/xcodebuild Languages: Java: version: 11.0.16 path: /usr/bin/javac Ruby: version: 2.7.5 path: /Users/jon.rigert/.rbenv/shims/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.3 wanted: 0.72.3 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: Not found newArchEnabled: Not found iOS: hermesEnabled: Not found newArchEnabled: Not found