Metro: [BUG] Metro still can't build on windows

Created on 3 Aug 2018  路  6Comments  路  Source: facebook/metro

Repro: Just build RNTester on windows.
Related issue: https://github.com/facebook/react-native/issues/20353, https://github.com/facebook/metro/issues/181.
From what I test, 0.42.1 works. But not 0.42.2, 0.43.1. 0.43.2., 0.43.3.
You can also see the appveyor build log: https://ci.appveyor.com/project/gengjiawen/react-native/build/1.0.22/job/it491en7tm6r69cq.

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)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Most helpful comment

We've just published Metro v0.43.4 which should fix the windows issues: https://github.com/facebook/metro/releases/tag/v0.43.4

All 6 comments

Thanks for the information @gengjiawen !

This means that we reintroduced the issue in one of the following commits: https://github.com/facebook/metro/compare/v0.42.1...v0.42.2

@pvdz The most probable thing that can be causing this issue is the upgrade to babel7-beta.54 + the revert of the windows dir normalization.

@gengjiawen can you test if v0.43.3 + a revert of https://github.com/facebook/metro/commit/0b70c9a5db55deb1bd21add57972d66c20c25e2e fixes the issue? if not can test it tomorrow (I'm in European time)

@rafeca is there an easy way I can test this. There are many packages in metro. And How do I replace the metro version in react native.

From what I test, 0.42.1 works. But not 0.42.2, 0.43.1. 0.43.2., 0.43.3.

uhm I'm confused now, how were you able to test that 0.42.1 works but not 0.42.2 without replacing the metro version in React Native?

It looks like the root issue comes from 0b70c9a, I'm reverting it and afterwards we're going to release a new version of Metro.

Thanks @gengjiawen for helping me debug it!

We've just published Metro v0.43.4 which should fix the windows issues: https://github.com/facebook/metro/releases/tag/v0.43.4

is there an easy way I can test this.

Just for future reference, I personally used something like this to test with other versions:

"resolutions": {
  "**/buck-worker-tool": "0.43.4",
  "**/metro": "0.43.4",
  "**/metro-babel-register": "0.43.4",
  "**/metro-babel7-plugin-react-transform": "0.43.4",
  "**/metro-cache": "0.43.4",
  "**/metro-config": "0.43.4",
  "**/metro-core": "0.43.4",
  "**/metro-memory-fs": "0.43.4",
  "**/metro-minify-uglify": "0.43.4",
  "**/metro-react-native-babel-preset": "0.43.4",
  "**/metro-resolver": "0.43.4",
  "**/metro-source-map": "0.43.4",
}

Add that to your package.json, and then run yarn.

You can also use the following snippet to force a specific version of Babel:

"resolutions": {
  "**/@babel/code-frame": "7.0.0-beta.48",
  "**/@babel/core": "7.0.0-beta.48",
  "**/@babel/generator": "7.0.0-beta.48",
  "**/@babel/helper-annotate-as-pure": "7.0.0-beta.48",
  "**/@babel/helper-builder-binary-assignment-operator-visitor": "7.0.0-beta.48",
  "**/@babel/helper-builder-react-jsx": "7.0.0-beta.48",
  "**/@babel/helper-call-delegate": "7.0.0-beta.48",
  "**/@babel/helper-define-map": "7.0.0-beta.48",
  "**/@babel/helper-explode-assignable-expression": "7.0.0-beta.48",
  "**/@babel/helper-function-name": "7.0.0-beta.48",
  "**/@babel/helper-get-function-arity": "7.0.0-beta.48",
  "**/@babel/helper-hoist-variables": "7.0.0-beta.48",
  "**/@babel/helper-member-expression-to-functions": "7.0.0-beta.48",
  "**/@babel/helper-module-imports": "7.0.0-beta.48",
  "**/@babel/helper-module-transforms": "7.0.0-beta.48",
  "**/@babel/helper-optimise-call-expression": "7.0.0-beta.48",
  "**/@babel/helper-plugin-utils": "7.0.0-beta.48",
  "**/@babel/helper-regex": "7.0.0-beta.48",
  "**/@babel/helper-remap-async-to-generator": "7.0.0-beta.48",
  "**/@babel/helper-replace-supers": "7.0.0-beta.48",
  "**/@babel/helper-simple-access": "7.0.0-beta.48",
  "**/@babel/helper-split-export-declaration": "7.0.0-beta.48",
  "**/@babel/helper-wrap-function": "7.0.0-beta.48",
  "**/@babel/helpers": "7.0.0-beta.48",
  "**/@babel/highlight": "7.0.0-beta.48",
  "**/@babel/plugin-external-helpers": "7.0.0-beta.48",
  "**/@babel/plugin-proposal-class-properties": "7.0.0-beta.48",
  "**/@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.48",
  "**/@babel/plugin-proposal-optional-chaining": "7.0.0-beta.48",
  "**/@babel/plugin-syntax-class-properties": "7.0.0-beta.48",
  "**/@babel/plugin-syntax-dynamic-import": "7.0.0-beta.48",
  "**/@babel/plugin-syntax-flow": "7.0.0-beta.48",
  "**/@babel/plugin-syntax-jsx": "7.0.0-beta.48",
  "**/@babel/plugin-syntax-nullish-coalescing-operator": "7.0.0-beta.48",
  "**/@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.48",
  "**/@babel/plugin-syntax-optional-chaining": "7.0.0-beta.48",
  "**/@babel/plugin-transform-arrow-functions": "7.0.0-beta.48",
  "**/@babel/plugin-transform-async-to-generator": "7.0.0-beta.48",
  "**/@babel/plugin-transform-block-scoping": "7.0.0-beta.48",
  "**/@babel/plugin-transform-classes": "7.0.0-beta.48",
  "**/@babel/plugin-transform-computed-properties": "7.0.0-beta.48",
  "**/@babel/plugin-transform-destructuring": "7.0.0-beta.48",
  "**/@babel/plugin-transform-exponentiation-operator": "7.0.0-beta.48",
  "**/@babel/plugin-transform-flow-strip-types": "7.0.0-beta.48",
  "**/@babel/plugin-transform-for-of": "7.0.0-beta.48",
  "**/@babel/plugin-transform-function-name": "7.0.0-beta.48",
  "**/@babel/plugin-transform-literals": "7.0.0-beta.48",
  "**/@babel/plugin-transform-modules-commonjs": "7.0.0-beta.48",
  "**/@babel/plugin-transform-object-assign": "7.0.0-beta.48",
  "**/@babel/plugin-transform-parameters": "7.0.0-beta.48",
  "**/@babel/plugin-transform-react-display-name": "7.0.0-beta.48",
  "**/@babel/plugin-transform-react-jsx": "7.0.0-beta.48",
  "**/@babel/plugin-transform-react-jsx-source": "7.0.0-beta.48",
  "**/@babel/plugin-transform-regenerator": "7.0.0-beta.48",
  "**/@babel/plugin-transform-shorthand-properties": "7.0.0-beta.48",
  "**/@babel/plugin-transform-spread": "7.0.0-beta.48",
  "**/@babel/plugin-transform-sticky-regex": "7.0.0-beta.48",
  "**/@babel/plugin-transform-template-literals": "7.0.0-beta.48",
  "**/@babel/plugin-transform-unicode-regex": "7.0.0-beta.48",
  "**/@babel/register": "7.0.0-beta.48",
  "**/@babel/template": "7.0.0-beta.48",
  "**/@babel/traverse": "7.0.0-beta.48",
  "**/@babel/types": "7.0.0-beta.48"
}
Was this page helpful?
0 / 5 - 0 ratings