Skip to content

Building with a typescript target fails on the second run #867

Open
@dancrumb

Description

@dancrumb

Description

The first time I run bob, I get:

 pnpm bob build
ℹ [module] Cleaning up previous build at lib/module
ℹ [typescript] Cleaning up previous build at lib/typescript
ℹ [typescript] Generating type definitions with tsc
⚠ [typescript] Failed to locate tsc in the workspace. Falling back to the binary found in PATH at /Users/dancrumb/Projects/Shoreditch/sutro-2-shoreditch/node_modules/.bin/tsc. Consider adding typescript to your devDependencies or specifying the tsc option for the typescript target.
ℹ [module] Compiling 147 files in src with babel
✔ [module] Wrote files to lib/module
✔ [typescript] Wrote definition files to lib/typescript

If I run it again, immediately, I get:

pnpm bob build
ℹ [module] Cleaning up previous build at lib/module
ℹ [typescript] Cleaning up previous build at lib/typescript
ℹ [typescript] Generating type definitions with tsc
⚠ [typescript] Failed to locate tsc in the workspace. Falling back to the binary found in PATH at /Users/dancrumb/Projects/Shoreditch/sutro-2-shoreditch/node_modules/.bin/tsc. Consider adding typescript to your devDependencies or specifying the tsc option for the typescript target.
ℹ [module] Compiling 147 files in src with babel
✖ [typescript] ENOENT: no such file or directory, open '/Users/dancrumb/Projects/Shoreditch/sutro-2-shoreditch/packages/core-components/lib/typescript/package.json'
bob build

build files for publishing

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --target   The target to build
               [string] [choices: "commonjs", "module", "typescript", "codegen"]

Error: Failed to build definition files.
    at Object.build [as typescript] (/Users/dancrumb/Projects/Shoreditch/sutro-2-shoreditch/node_modules/react-native-builder-bob/lib/targets/typescript.js:206:11) {
  [cause]: [Error: ENOENT: no such file or directory, open '/Users/dancrumb/Projects/Shoreditch/sutro-2-shoreditch/packages/core-components/lib/typescript/package.json'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'open',
    path: '/Users/dancrumb/Projects/Shoreditch/sutro-2-shoreditch/packages/core-components/lib/typescript/package.json'
  }
}

Packages

  • create-react-native-library
  • react-native-builder-bob

Selected options

Here's my package.json

{
  "name": "@sutro/core-components",
  "version": "v1.0.0",
  "exports": {
    ".": {
      "source": "./src/index.ts",
      "types": "./lib/typescript/index.d.ts",
      "default": "./lib/module/index.js"
    },
    "./package.json": "./package.json"
  },
  "type": "module",
  "scripts": {
    "build": "tsc",
    "build:docs": "typedoc --out docs",
    "check-types": "tsc --noEmit",
    "lint": "eslint",
    "lint:fix": "eslint --fix",
    "test": "vitest run",
    "test:ci": "vitest run --reporter junit --output-file reports/report.xml  --reporter default",
    "test:watch": "vitest",
    "prepare": "bob build"
  },
  "peerDependencies": {
    "tsyringe-neo": "catalog:",
    "react": "catalog:react19.1",
    "expo": "53.0.9",
    "@sutro/event-bus": "workspace:^",
    "@sutro/expressions": "workspace:^",
    "@sutro/workflow-engine": "workspace:^"
  },
  "dependencies": {
    "@radix-ui/react-dialog": "^1.1.14",
    "@radix-ui/react-popover": "^1.1.14",
    "@radix-ui/react-select": "^2.2.5",
    "@sutro/app-definition-types": "workspace:^",
    "@sutro/common": "workspace:^",
    "@sutro/rendering-engine": "workspace:^",
    "@sutro/rn-primitives": "workspace:^",
    "@sutro/tsconfig": "workspace:^",
    "@sutro/utility-types": "workspace:^",
    "class-variance-authority": "^0.7.1",
    "clsx": "^2.1.1",
    "cmdk": "1.0.0",
    "date-fns": "^4.1.0",
    "lucide-react": "^0.477.0",
    "lucide-react-native": "^0.503.0",
    "nativewind": "^4.1.23",
    "observable-hooks": "^4.2.4",
    "react-day-picker": "8.10.1",
    "react-native": "~0.79.4",
    "react-native-reanimated": "3.17.4",
    "recharts": "^2.15.4",
    "sonner": "^2.0.5",
    "tailwind-merge": "^3.3.1",
    "tailwindcss": "^4.1.11",
    "tslib": "catalog:",
    "ulid": "catalog:",
    "use-constant": "^2.0.0",
    "usehooks-ts": "^3.1.1",
    "zustand": "^5.0.6"
  },
  "devDependencies": {
    "@eslint/js": "^9.21.0",
    "@storybook/react": "^9.0.15",
    "@sutro/eslint-config": "workspace:^",
    "@vitest/coverage-v8": "catalog:",
    "@babel/plugin-proposal-class-properties": "*",
    "babel-plugin-transform-typescript-metadata": "*",
    "eslint": "catalog:",
    "globals": "^16.0.0",
    "react-native-builder-bob": "^0.40.12",
    "typedoc": "^0.27.8",
    "typescript": "catalog:",
    "typescript-eslint": "^8.25.0",
    "vitest": "catalog:"
  },
  "main": "./lib/module/index.js",
  "types": "./lib/typescript/index.d.ts",
  "files": [
    "src",
    "lib",
    "!**/__tests__",
    "!**/__fixtures__",
    "!**/__mocks__"
  ],
  "react-native-builder-bob": {
    "source": "src",
    "output": "lib",
    "targets": [
      [
        "module",
        {
          "esm": true,
          "configFile": true
        }
      ],
      "typescript"
    ]
  },
  "eslintIgnore": [
    "node_modules/",
    "lib/"
  ]
}

Link to repro

Unfortunately, I'm seeing this in a project that I can't share

Environment

macos Sequoia 15.5

npx react-native info
info Fetching system and libraries information...
System:
  OS: macOS 15.5
  CPU: (10) arm64 Apple M1 Pro
  Memory: 122.22 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.14.0
    path: ~/.nvm/versions/node/v22.14.0/bin/node
  Yarn: Not Found
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v22.14.0/bin/npm
  Watchman:
    version: 2025.04.28.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12700392
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 23
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

info React Native v0.80.1 is now available (your project is running on v0.79.4).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.80.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.4&to=0.80.1
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions