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

Packager build error on Windows: "Unexpected identifier" or "Unable to resolve a Haste module" #20353

Closed
gengjiawen opened this issue Jul 23, 2018 · 35 comments
Labels
Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Platform: Windows Building on Windows. Ran Commands One of our bots successfully processed a command. Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot. Type: Discussion Long running discussion.

Comments

@gengjiawen
Copy link
Contributor

gengjiawen commented Jul 23, 2018

I first discover this issue in June 16 (facebook/metro#181), which is a month ago, but got less attention on this in beggining. Then react native 0.56 released, which totally expose the problem, which bothering windows user even for now (see #20346 and facebook/metro#200).

Here is what I want to have been achieve

Fix debug RNTester on windows (merged in 2018-08-04)

Related pr: #19974.
The main purpose is refactor bash script to nodejs script, so it can be cross platform. I remove some types on file simplily because they not flow-typed file. @pvdz Please merge this asap. For without it, debugging RNTester will be an unusable on windows

Fix RNTester in release mode on windows (merged on 18/07/31)

Related pr: #20293.
This is a windows specific bug. And this bothered me very long time , I searched really really a lot to fix it.
Without it you will have build problem like this:

* What went wrong:
Failed to capture snapshot of input files for task ':RNTester:android:app:bundleReleaseJsAndAssets' property '$1' during up-to-date check.
> Failed to create MD5 hash for file content.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

I think it's clean fix and I have appveyor log to prove my fix work, you can see detail in that pr. So I hope @hramos or anyone with merge permission can review my pr.

Fix general problem like

Problem like SyntaxError: Unexpected identifier or 'Unable to resolve a haste module' or 'Unable to resolve a module' has been fixed in master branch by the help of metro team. But when I communicate with @kelset , branch 0.57 still not working. But I believe we can fix that soon.

And Many developers works on windows instead of macOS. And this has been take too long to fix. And there are many windows developer still suffer from this issue in today.

In the end, I love react native. But dear react native official members, don't make us wait too long.

@react-native-bot

This comment has been minimized.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. 📋No Template labels Jul 23, 2018
@hramos hramos added the Type: Discussion Long running discussion. label Jul 23, 2018
@hramos
Copy link
Contributor

hramos commented Jul 23, 2018

Reopening with "For Discussion" label. For future reference, if you use the provided "For Discussion" template, this would be done automatically by the bot.

@hramos hramos reopened this Jul 23, 2018
@hramos hramos added Platform: Windows Building on Windows. and removed 📋No Template labels Jul 23, 2018
@gengjiawen
Copy link
Contributor Author

@hramos Can you review this pr #20293.

@kelset
Copy link
Collaborator

kelset commented Jul 24, 2018

👋 Jiawen, thanks for the writeup!
Sadly as I mentioned my powers over reviewing and merging are limited.

Can I ask you a side question? You say

Problem like SyntaxError: Unexpected identifier or 'Unable to resolve a haste module' or 'Unable to resolve a module' has been fixed in master branch [..] but [..] , branch 0.57 still not working

Do you see any commit present in the master branch that is not on the 0.57 one?

cc @grabbou any idea of why it may work on one and not the other?

@gengjiawen
Copy link
Contributor Author

@kelset The master branch when I tested works not metro 0.42.2, I will test the latest master branch again.

@gengjiawen
Copy link
Contributor Author

The lastest master branch is broken again.

import type {CommandT} from './commands';
       ^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:74:7)
    at createScript (vm.js:246:10)
    at Object.runInThisContext (vm.js:298:10)
    at Module._compile (internal/modules/cjs/loader.js:657:28)
    at Module._compile (D:\Developer\react-native\node_modules\pirates\lib\index.js:83:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (D:\Developer\react-native\node_modules\pirates\lib\index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@kelset
Copy link
Collaborator

kelset commented Jul 24, 2018

cc @rafeca

@gengjiawen
Copy link
Contributor Author

Confirmed, 0.42.1 works fine.

    "metro": "0.42.1",
    "metro-babel-register": "0.42.1",
    "metro-core": "0.42.1",
    "metro-memory-fs": "0.42.1",

@harshulsharma0000
Copy link

@gengjiawen Neither 0.42.1 nor 0.42.2 work on my machine getting
import type {CommandT} from './commands';
On which version did you try?

@gengjiawen
Copy link
Contributor Author

gengjiawen commented Jul 26, 2018

I think I am pretty clear, 0.42.1 works. I test it on react native master branch.

@gengjiawen
Copy link
Contributor Author

@hramos @rafeca Can we get this done ? This has been bothering windows user for over a month.

@hramos
Copy link
Contributor

hramos commented Jul 26, 2018

@gengjiawen I'm aware of this, and other PRs. We just held a day-long event for React and React Native contributors here at the office, and we're now finishing our roadmap and a proposal to help move PRs along faster. It does require that we take a break from looking at our GitHub notifications for a bit so we can focus, but in the long term it should have a beneficial effect on the repo.

For the time being, please work with any of our other core contributors, and thank you for your patience.

@aaronschubert0
Copy link

@hramos That's awesome to hear, will the roadmap be shared publicly or just used internally? Would be very helpful to gain some insights from the roadmap.

@facebook facebook deleted a comment Jul 27, 2018
@hramos
Copy link
Contributor

hramos commented Jul 27, 2018

@aaronschubert0 you can take a look at meetings notes from the core team, as well as any proposals, over at https://github.com/react-native-community/discussions-and-proposals. This is a work in progress, but the plan is to fill that repo out with any ongoing work from the community. As for the React Native team at Facebook, we just broadcast a tech talk this week which covers our ongoing work on the new React Native architecture codenamed "Fabric": https://www.facebook.com/hramos/videos/10101317533036249

@aaronschubert0
Copy link

@hramos Great thanks a lot, appreciate the insights.

@Wolf00Bomber
Copy link

Any headway over the issue reported at this link below would be helpful, as we are not able to build the App using react-native run-android CMD:
#19953 (comment)

@gengjiawen
Copy link
Contributor Author

gengjiawen commented Aug 1, 2018

Update:

  • Metro 0.43.1 still not working, the build on master branch is still broken on windows.
  • Release version (gradlew RNTester:android:app:assembleRelease ) not working on latest master branch too.
  • The debug fix pr still need to be merged Fix RNTester on Windows #19974, still waiting for approval.

Error log for release mode:

> Task :RNTester:android:app:bundleReleaseJsAndAssets FAILED
D:\Developer\react-native\local-cli\cliEntry.js:30
import type {CommandT} from './commands';
       ^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:74:7)
    at createScript (vm.js:246:10)
    at Object.runInThisContext (vm.js:298:10)
    at Module._compile (internal/modules/cjs/loader.js:657:28)
    at Module._compile (D:\Developer\react-native\node_modules\pirates\lib\index.js:83:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (D:\Developer\react-native\node_modules\pirates\lib\index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

@facebook facebook deleted a comment from gengjiawen Aug 1, 2018
@gengjiawen
Copy link
Contributor Author

@gengjiawen
Copy link
Contributor Author

Metro 0.43.2 not working too.

@victorhugoweb
Copy link

please help us - Windows developers are human too. We need support too.

@westinyang

This comment has been minimized.

@fungilation
Copy link

fungilation commented Aug 2, 2018

Moving my project from my ancient MacBook to my shiny new PC, I got a whole bunch of errors while trying to build for Android on Windows 10 before I keep hitting on build issue like #14209, #19953 and oblador/react-native-vector-icons#429.

I'm on RN 0.56.0. No issue on Mac building for either iOS or Android. But all sorts of issues building on Windows for Android.

Hopefully these issues get addressed in RN 0.57 and it's ready soon.

@nicolashemonic
Copy link

Same issue, works great on MacOS and get unexpected token error on Windows.

@kelset
Copy link
Collaborator

kelset commented Aug 2, 2018

While I understand everyone frustration with this Windows issue, let me be extremely clear on the fact that if this issue becomes a series of "me too" comments or worse I'll lock it.

As mentioned many times before, this is an open source project - so you're entitled to the level of support you pay for and that's: none.

I've been personally trying to having this fixed since the first RCs of 0.56, but I'm not a Windows user so it's really hard to check the attempted fixes.

You want to help? Investigate what is causing this issue and submit PRs to fix it (as @gengjiawen has been doing). (in particular, if you are a developer in London or the EU timezone pls DM me on twitter so we can try to create a shorter feedback loop)

@fungilation
Copy link

fungilation commented Aug 2, 2018

Can this become a viable solution to officially support Windows deployment by relying on the Windows Linux subsystem? The great thing with this is the whole RN toolchain would then be the same as Mac/Linux's by running inside WSL. The setup would obviously be more complicated to have install files on native Windows so it's exposed to the GUI code editor while still giving fs/executable access from WSL, but having a single Linux-like environment for RN build to support instead of split with Windows' (which also breaks in all sorts of other "interesting" ways like permissions to create/delete files/folders as I've encountered trying to setup my RN env on Windows) seems very appealing. RN also doesn't need to consider alternative CI testing on Windows either then.

PS. My comment was/is not a me too comment. I was highlight different issues I faced while migrating to Windows (from Mac). If you want the community to help, you have to be more specific in terms of what you need in testing. And this is a discussion thread is this not? Agreed that as long as comments aren't "just" me too. Group hug on helping each other out in moving RN forward, together.

@gengjiawen
Copy link
Contributor Author

I tried the new 0.43.3, not working too. I think I need to open a issue to on metro since I can not reopen my old issue.

@gengjiawen
Copy link
Contributor Author

Reported via facebook/metro#213.

@kelset How about we downgrade metro to 0.42.1 on branch 0.57 ?

@Parisasuchdev

This comment has been minimized.

@gengjiawen
Copy link
Contributor Author

gengjiawen commented Aug 3, 2018

Confirmed metro 0.43.4 works. @kelset @grabbou we can start prepare for a new release.
cc @rafeca @hramos .

@gengjiawen
Copy link
Contributor Author

All my windows related pr has been merged, you can play with react native code on windows now. Have fun :)

@fungilation
Copy link

fungilation commented Aug 3, 2018

Thanks a lot @gengjiawen.

Is a 0.57 RC dropping soon so I can test with react-native-git-upgrade?

@Dimous

This comment has been minimized.

@gengjiawen
Copy link
Contributor Author

@hramos Appveyor looks like not triggered on master branch, can you check this ? Thanks.

@facebook facebook locked as resolved and limited conversation to collaborators Aug 6, 2018
@kelset
Copy link
Collaborator

kelset commented Aug 6, 2018

Until 0.57 lands I think we should keep this open.

@hramos
Copy link
Contributor

hramos commented Aug 17, 2018

The 0.57 RC is now available. Please try it out and let us know if this is still an issue.

@hramos hramos added the Resolution: Fixed A PR that fixes this issue has been merged. label Aug 17, 2018
@hramos hramos changed the title Let's fix build problem on windows Packager build error on Windows: "Unexpected identifier" or "Unable to resolve a Haste module" Aug 17, 2018
@hramos hramos added the Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. label Aug 17, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Platform: Windows Building on Windows. Ran Commands One of our bots successfully processed a command. Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot. Type: Discussion Long running discussion.
Projects
None yet
Development

No branches or pull requests