Skip to content

examples/create-react-app is broken on Apple M1 #3101

@z-k-r

Description

@z-k-r

🐞 bug report

Affected Rule

create-react-app example

Is this a regression?

No

Description

Example for create-react-app does not built on Apple M1 because NodeJS versions below 16 are not supported (relevant)

🔬 Minimal Reproduction

On an Apple M1 machine, run:

git clone https://github.com/bazelbuild/rules_nodejs.git
cd rules_nodejs/examples/create-react-app
bazel run //:start

It results in the error seen below. Same command succeeds when run on Ubuntu (I don't have an Intel Mac ready to test)

🔥 Exception or Error


INFO: Repository npm instantiated at:
  /Users/zak/src/external/rules_nodejs/examples/create-react-app/WORKSPACE:25:13: in 
  /private/var/tmp/_bazel_zak/cb27351f3f761fcb61f542608d914ae9/external/build_bazel_rules_nodejs/index.bzl:83:18: in yarn_install
Repository rule yarn_install defined at:
  /private/var/tmp/_bazel_zak/cb27351f3f761fcb61f542608d914ae9/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:917:31: in 
ERROR: An error occurred during the fetch of repository 'npm':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_zak/cb27351f3f761fcb61f542608d914ae9/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 814, column 31, in _yarn_install_impl
		node = repository_ctx.path(get_node_label(repository_ctx))
Error in path: Unable to load package for @nodejs_darwin_arm64//:bin/node: The repository '@nodejs_darwin_arm64' could not be resolved
ERROR: Error fetching repository: Traceback (most recent call last):
	File "/private/var/tmp/_bazel_zak/cb27351f3f761fcb61f542608d914ae9/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 814, column 31, in _yarn_install_impl
		node = repository_ctx.path(get_node_label(repository_ctx))
Error in path: Unable to load package for @nodejs_darwin_arm64//:bin/node: The repository '@nodejs_darwin_arm64' could not be resolved
ERROR: Skipping '//:start': no such package '@npm//react-scripts': Unable to load package for @nodejs_darwin_arm64//:bin/node: The repository '@nodejs_darwin_arm64' could not be resolved
WARNING: Target pattern parsing failed.
ERROR: no such package '@npm//react-scripts': Unable to load package for @nodejs_darwin_arm64//:bin/node: The repository '@nodejs_darwin_arm64' could not be resolved
INFO: Elapsed time: 0.163s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
    currently loading:

🌍 Your Environment

Operating System:

  
MacOS 11.6 Big Sur
  

Output of bazel version:

  
Build label: 4.2.1
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Aug 30 15:23:11 2021 (1630336991)
Build timestamp: 1630336991
Build timestamp as int: 1630336991
  

Rules_nodejs version:

(Please check that you have matching versions between WORKSPACE file and @bazel/* npm packages.)

  
latest stable (653600d99cd8be75ba1f149a1a5d95a67354ea2d)
  

Anything else relevant?
Proposed fix inspired by @PengKuang in discussion for #2733

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions