Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(windows): fix builder-bob failing to find tsc #387

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tido64
Copy link

@tido64 tido64 commented Dec 3, 2024

Nitro currently fails to build on a Windows machine:

$ bun run build
$ bun run --cwd packages/react-native-nitro-modules build && bun run --cwd packages/nitrogen build && bun run --cwd packages/react-native-nitro-image build
$ rm -rf lib && bun typecheck && bob build
$ tsc --noEmit
ℹ Building target commonjs
ℹ Cleaning up previous build at lib\commonjs
ℹ Building target module
ℹ Cleaning up previous build at lib\module
ℹ Building target typescript
ℹ Cleaning up previous build at lib\typescript
ℹ Compiling 10 files in src with babel
ℹ Compiling 10 files in src with babel
ℹ Generating type definitions with tsc
✖ The tsc binary doesn't seem to be installed at D:\nitro\node_modules\.bin\tsc. Please specify the correct path in options or remove it to use the workspace's version.
D:\nitro\node_modules\react-native-builder-bob\lib\targets\typescript.js:194
    throw new Error('Failed to build definition files.');
          ^

Error: Failed to build definition files.
    at build (D:\nitro\node_modules\react-native-builder-bob\lib\targets\typescript.js:194:11)
    at async buildTarget (D:\nitro\node_modules\react-native-builder-bob\lib\index.js:416:7)

Node.js v20.17.0
error: script "build" exited with code 1
error: script "build" exited with code 1

The reason is because we're specifying a Unix-specific path in package.json. Removing it makes things build, but we get this warning instead:

⚠ Failed to locate tsc in the workspace. Falling back to the binary found in PATH at D:\nitro\node_modules\.bin\tsc.EXE. Consider adding typescript to your devDependencies or specifying the tsc option for the typescript target.

Even after I've added typescript to devDependencies, this warning still appears. I suspect it's a bug in builder-bob, but I haven't looked into it.

Copy link

vercel bot commented Dec 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nitro-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 3, 2024 5:47pm

@mrousavy
Copy link
Owner

mrousavy commented Dec 4, 2024

@chrispader can you confirm that this will still work with our monorepo setup?

@chrispader
Copy link
Contributor

hmm, the reason we specify the tsc location is because otherwise react-native-builder-bob will warn that it uses the global typescript package.

Adding the typescript dependency will prevent hoisting of the package in the root, but BuilderBob can find it.

We can either not hoist it, or fix this for non-unix platforms

@mrousavy
Copy link
Owner

mrousavy commented Dec 4, 2024

I would prefer to use the same TypeScript version for all modules here to avoid any version conflicts, so I think hoisting is the best approach right?

@chrispader
Copy link
Contributor

yes, i'd also agree

@mrousavy
Copy link
Owner

I'm running into the same issue now on Windows.. 😅

@fax1ty
Copy link

fax1ty commented Jan 2, 2025

Should this be cancelled in favor of packages/react-native-nitro-modules/package.json?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants