facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.26k stars 24.35k forks source link

0.69.0 can not init new project #34076

Closed liresky closed 2 years ago

liresky commented 2 years ago

Description

when I create a new project with 0.69.0.

/Users/resky/.config/yarn/global/node_modules/react-native-cli/index.js:302 cli.init(root, projectName); ^

TypeError: cli.init is not a function at run (/Users/resky/.config/yarn/global/node_modules/react-native-cli/index.js:302:7) at createProject (/Users/resky/.config/yarn/global/node_modules/react-native-cli/index.js:249:3) at init (/Users/resky/.config/yarn/global/node_modules/react-native-cli/index.js:200:5) at Object. (/Users/resky/.config/yarn/global/node_modules/react-native-cli/index.js:153:7) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) at internal/main/run_main_module.js:17:47

There is the error. but 0.68.2 is ok. node version 16.15.1,14.19.3 all is failed.

Version

0.69.0

Output of npx react-native info

info Fetching system and libraries information... System: OS: macOS 12.4 CPU: (4) x64 Intel(R) Core(TM) i5-7287U CPU @ 3.30GHz Memory: 485.27 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.15.1 - /usr/local/bin/node Yarn: 1.22.18 - ~/.yarn/bin/yarn npm: 8.13.1 - /usr/local/bin/npm Watchman: 2022.06.20.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8193401 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 17.0.3 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: 0.69.0 => 0.69.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

npx react-native init smart

Snack, code example, screenshot, or link to a repository

(base) ➜ temp npx react-native init smart This will walk you through creating a new React Native project in /Users/resky/work/temp/smart Using yarn v1.22.19 Installing react-native... yarn add v1.22.19 info No lockfile found. [1/4] 🔍 Resolving packages... warning react-native > @react-native-community/cli > @react-native-community/cli-plugin-metro > metro > metro-minify-uglify > uglify-es@3.3.9: support for ECMAScript is superseded by uglify-js as of v3.13.0 warning react-native > react-native-codegen > jscodeshift > micromatch > snapdragon > source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated warning react-native > react-native-codegen > jscodeshift > micromatch > snapdragon > source-map-resolve > source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated warning react-native > react-native-codegen > jscodeshift > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated warning react-native > react-native-codegen > jscodeshift > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... warning "react-native > metro-react-native-babel-transformer@0.70.3" has unmet peer dependency "@babel/core@*". warning "react-native > react-shallow-renderer@16.14.1" has unmet peer dependency "react@^16.0.0 || ^17.0.0". warning "react-native > use-sync-external-store@1.2.0" has unmet peer dependency "react@^16.8.0 || ^17.0.0 || ^18.0.0". warning "react-native > react-native-codegen > jscodeshift@0.13.1" has unmet peer dependency "@babel/preset-env@^7.1.6". warning " > react-native@0.69.0" has unmet peer dependency "react@18.0.0". info There appears to be trouble with your network connection. Retrying... [4/4] 🔨 Building fresh packages... success Saved lockfile. success Saved 375 new dependencies. info Direct dependencies └─ react-native@0.69.0 info All dependencies ├─ @ampproject/remapping@2.2.0 ├─ @babel/compat-data@7.18.5 ├─ @babel/helper-builder-binary-assignment-operator-visitor@7.16.7 ├─ @babel/helper-compilation-targets@7.18.2 ├─ @babel/helper-create-class-features-plugin@7.18.0 ├─ @babel/helper-create-regexp-features-plugin@7.17.12 ├─ @babel/helper-explode-assignable-expression@7.16.7 ├─ @babel/helper-hoist-variables@7.16.7 ├─ @babel/helper-module-imports@7.16.7 ├─ @babel/helper-plugin-utils@7.17.12 ├─ @babel/helper-simple-access@7.18.2 ├─ @babel/helper-wrap-function@7.16.8 ├─ @babel/helpers@7.18.2 ├─ @babel/highlight@7.17.12 ├─ @babel/plugin-proposal-async-generator-functions@7.17.12 ├─ @babel/plugin-proposal-class-properties@7.17.12 ├─ @babel/plugin-proposal-export-default-from@7.17.12 ├─ @babel/plugin-proposal-nullish-coalescing-operator@7.17.12 ├─ @babel/plugin-proposal-optional-catch-binding@7.16.7 ├─ @babel/plugin-proposal-optional-chaining@7.17.12 ├─ @babel/plugin-syntax-async-generators@7.8.4 ├─ @babel/plugin-syntax-class-properties@7.12.13 ├─ @babel/plugin-syntax-dynamic-import@7.8.3 ├─ @babel/plugin-syntax-export-default-from@7.16.7 ├─ @babel/plugin-syntax-flow@7.17.12 ├─ @babel/plugin-syntax-jsx@7.17.12 ├─ @babel/plugin-syntax-nullish-coalescing-operator@7.8.3 ├─ @babel/plugin-syntax-object-rest-spread@7.8.3 ├─ @babel/plugin-syntax-optional-catch-binding@7.8.3 ├─ @babel/plugin-syntax-optional-chaining@7.8.3 ├─ @babel/plugin-syntax-typescript@7.17.12 ├─ @babel/plugin-transform-async-to-generator@7.17.12 ├─ @babel/plugin-transform-block-scoped-functions@7.16.7 ├─ @babel/plugin-transform-exponentiation-operator@7.16.7 ├─ @babel/plugin-transform-flow-strip-types@7.17.12 ├─ @babel/plugin-transform-for-of@7.18.1 ├─ @babel/plugin-transform-member-expression-literals@7.16.7 ├─ @babel/plugin-transform-modules-commonjs@7.18.2 ├─ @babel/plugin-transform-named-capturing-groups-regex@7.17.12 ├─ @babel/plugin-transform-object-super@7.16.7 ├─ @babel/plugin-transform-parameters@7.17.12 ├─ @babel/plugin-transform-property-literals@7.16.7 ├─ @babel/plugin-transform-react-jsx-self@7.17.12 ├─ @babel/plugin-transform-react-jsx-source@7.16.7 ├─ @babel/plugin-transform-runtime@7.18.5 ├─ @babel/plugin-transform-sticky-regex@7.16.7 ├─ @babel/plugin-transform-typescript@7.18.4 ├─ @babel/plugin-transform-unicode-regex@7.16.7 ├─ @babel/preset-flow@7.17.12 ├─ @babel/preset-typescript@7.17.12 ├─ @babel/register@7.17.7 ├─ @babel/runtime@7.18.3 ├─ @babel/traverse@7.18.5 ├─ @hapi/topo@5.1.0 ├─ @jest/create-cache-key-function@27.5.1 ├─ @jridgewell/gen-mapping@0.1.1 ├─ @jridgewell/resolve-uri@3.0.7 ├─ @react-native-community/cli-clean@8.0.0 ├─ @react-native-community/cli-doctor@8.0.2 ├─ @react-native-community/cli-hermes@8.0.2 ├─ @react-native-community/cli-platform-android@8.0.2 ├─ @react-native-community/cli-platform-ios@8.0.2 ├─ @react-native-community/cli-plugin-metro@8.0.0 ├─ @react-native-community/cli-types@8.0.0 ├─ @react-native-community/cli@8.0.2 ├─ @react-native/assets@1.0.0 ├─ @react-native/normalize-color@2.0.0 ├─ @react-native/polyfills@2.0.0 ├─ @sideway/address@4.1.4 ├─ @sideway/formula@3.0.0 ├─ @sideway/pinpoint@2.0.0 ├─ @types/graceful-fs@4.1.5 ├─ @types/istanbul-lib-coverage@2.0.4 ├─ @types/istanbul-lib-report@3.0.0 ├─ @types/yargs@16.0.4 ├─ abort-controller@3.0.0 ├─ accepts@1.3.8 ├─ anser@1.4.10 ├─ ansi-fragments@0.2.1 ├─ ansi-regex@5.0.1 ├─ anymatch@3.1.2 ├─ appdirsjs@1.2.6 ├─ argparse@1.0.10 ├─ arr-flatten@1.1.0 ├─ asap@2.0.6 ├─ assign-symbols@1.0.0 ├─ ast-types@0.14.2 ├─ astral-regex@1.0.0 ├─ async-limiter@1.0.1 ├─ async@3.2.4 ├─ atob@2.1.2 ├─ babel-core@7.0.0-bridge.0 ├─ babel-plugin-dynamic-import-node@2.3.3 ├─ babel-plugin-polyfill-corejs2@0.3.1 ├─ babel-plugin-polyfill-corejs3@0.5.2 ├─ babel-plugin-polyfill-regenerator@0.3.1 ├─ babel-plugin-syntax-trailing-function-commas@7.0.0-beta.0 ├─ balanced-match@1.0.2 ├─ base@0.11.2 ├─ base64-js@1.5.1 ├─ bl@4.1.0 ├─ brace-expansion@1.1.11 ├─ braces@2.3.2 ├─ browserslist@4.21.0 ├─ bser@2.1.1 ├─ buffer-from@1.1.2 ├─ buffer@5.7.1 ├─ bytes@3.0.0 ├─ cache-base@1.0.1 ├─ call-bind@1.0.2 ├─ caller-callsite@2.0.0 ├─ caller-path@2.0.0 ├─ callsites@2.0.0 ├─ camelcase@5.3.1 ├─ caniuse-lite@1.0.30001359 ├─ ci-info@2.0.0 ├─ class-utils@0.3.6 ├─ cli-cursor@3.1.0 ├─ cli-spinners@2.6.1 ├─ cliui@6.0.0 ├─ clone-deep@4.0.1 ├─ clone@1.0.4 ├─ collection-visit@1.0.0 ├─ color-convert@2.0.1 ├─ color-name@1.1.4 ├─ colorette@1.4.0 ├─ command-exists@1.2.9 ├─ commander@2.20.3 ├─ commondir@1.0.1 ├─ compressible@2.0.18 ├─ compression@1.7.4 ├─ concat-map@0.0.1 ├─ convert-source-map@1.8.0 ├─ copy-descriptor@0.1.1 ├─ core-js-compat@3.23.3 ├─ core-util-is@1.0.3 ├─ cosmiconfig@5.2.1 ├─ cross-spawn@6.0.5 ├─ dayjs@1.11.3 ├─ debug@2.6.9 ├─ decode-uri-component@0.2.0 ├─ deepmerge@3.3.0 ├─ defaults@1.0.3 ├─ define-properties@1.1.4 ├─ denodeify@1.2.1 ├─ destroy@1.2.0 ├─ electron-to-chromium@1.4.170 ├─ emoji-regex@8.0.0 ├─ end-of-stream@1.4.4 ├─ envinfo@7.8.1 ├─ error-ex@1.3.2 ├─ error-stack-parser@2.1.4 ├─ errorhandler@1.5.1 ├─ escalade@3.1.1 ├─ escape-string-regexp@1.0.5 ├─ esprima@4.0.1 ├─ etag@1.8.1 ├─ event-target-shim@5.0.1 ├─ expand-brackets@2.1.4 ├─ extglob@2.0.4 ├─ fb-watchman@2.0.1 ├─ fill-range@4.0.0 ├─ finalhandler@1.1.2 ├─ find-cache-dir@2.1.0 ├─ flow-parser@0.121.0 ├─ for-in@1.0.2 ├─ fresh@0.5.2 ├─ fs.realpath@1.0.0 ├─ fsevents@2.3.2 ├─ gensync@1.0.0-beta.2 ├─ get-caller-file@2.0.5 ├─ get-intrinsic@1.1.2 ├─ get-stream@4.1.0 ├─ get-value@2.0.6 ├─ has-property-descriptors@1.0.0 ├─ has-symbols@1.0.3 ├─ has-value@1.0.0 ├─ hermes-engine@0.11.0 ├─ hermes-estree@0.6.0 ├─ http-errors@2.0.0 ├─ ieee754@1.2.1 ├─ image-size@0.6.3 ├─ import-fresh@2.0.0 ├─ imurmurhash@0.1.4 ├─ inflight@1.0.6 ├─ inherits@2.0.4 ├─ is-accessor-descriptor@1.0.0 ├─ is-arrayish@0.2.1 ├─ is-core-module@2.9.0 ├─ is-data-descriptor@1.0.0 ├─ is-descriptor@1.0.2 ├─ is-directory@0.3.1 ├─ is-fullwidth-code-point@2.0.0 ├─ is-interactive@1.0.0 ├─ is-plain-object@2.0.4 ├─ is-stream@1.1.0 ├─ is-windows@1.0.2 ├─ is-wsl@1.1.0 ├─ isarray@1.0.0 ├─ isexe@2.0.0 ├─ jest-get-type@26.3.0 ├─ jest-regex-util@27.5.1 ├─ jest-serializer@27.5.1 ├─ jest-util@27.5.1 ├─ jest-validate@26.6.2 ├─ jest-worker@27.5.1 ├─ jetifier@1.6.8 ├─ js-tokens@4.0.0 ├─ jsc-android@250230.2.1 ├─ jscodeshift@0.13.1 ├─ jsesc@2.5.2 ├─ json-parse-better-errors@1.0.2 ├─ json5@2.2.1 ├─ jsonfile@4.0.0 ├─ klaw@1.3.1 ├─ kleur@3.0.3 ├─ locate-path@5.0.0 ├─ lodash.debounce@4.0.8 ├─ log-symbols@4.1.0 ├─ logkitty@0.7.1 ├─ loose-envify@1.4.0 ├─ make-dir@2.1.0 ├─ makeerror@1.0.12 ├─ map-visit@1.0.0 ├─ memoize-one@5.2.1 ├─ merge-stream@2.0.0 ├─ metro-config@0.70.3 ├─ metro-inspector-proxy@0.70.3 ├─ metro-minify-uglify@0.70.3 ├─ metro-react-native-babel-transformer@0.70.3 ├─ metro-transform-worker@0.70.3 ├─ micromatch@3.1.10 ├─ mime-db@1.52.0 ├─ mime-types@2.1.35 ├─ mime@2.6.0 ├─ mimic-fn@2.1.0 ├─ minimatch@3.1.2 ├─ minimist@1.2.6 ├─ mixin-deep@1.3.2 ├─ mkdirp@0.5.6 ├─ ms@2.0.0 ├─ nanomatch@1.2.13 ├─ negotiator@0.6.3 ├─ neo-async@2.6.2 ├─ nice-try@1.0.5 ├─ nocache@3.0.4 ├─ node-dir@0.1.17 ├─ node-fetch@2.6.7 ├─ node-int64@0.4.0 ├─ node-releases@2.0.5 ├─ node-stream-zip@1.15.0 ├─ normalize-path@3.0.0 ├─ npm-run-path@2.0.2 ├─ ob1@0.70.3 ├─ object-assign@4.1.1 ├─ object-copy@0.1.0 ├─ object.assign@4.1.2 ├─ on-finished@2.4.1 ├─ on-headers@1.0.2 ├─ once@1.4.0 ├─ onetime@5.1.2 ├─ open@6.4.0 ├─ os-tmpdir@1.0.2 ├─ p-finally@1.0.0 ├─ p-limit@2.3.0 ├─ p-locate@4.1.0 ├─ p-try@2.2.0 ├─ parse-json@4.0.0 ├─ pascalcase@0.1.1 ├─ path-exists@4.0.0 ├─ path-is-absolute@1.0.1 ├─ path-key@2.0.1 ├─ path-parse@1.0.7 ├─ picocolors@1.0.0 ├─ picomatch@2.3.1 ├─ pify@4.0.1 ├─ pirates@4.0.5 ├─ pkg-dir@3.0.0 ├─ plist@3.0.5 ├─ posix-character-classes@0.1.1 ├─ process-nextick-args@2.0.1 ├─ promise@8.1.0 ├─ pump@3.0.0 ├─ range-parser@1.2.1 ├─ react-devtools-core@4.24.0 ├─ react-is@17.0.2 ├─ react-native-codegen@0.69.1 ├─ react-native-gradle-plugin@0.0.7 ├─ react-native@0.69.0 ├─ react-shallow-renderer@16.14.1 ├─ readable-stream@3.6.0 ├─ readline@1.3.0 ├─ recast@0.20.5 ├─ regenerate-unicode-properties@10.0.1 ├─ regenerator-runtime@0.13.9 ├─ regexpu-core@5.0.1 ├─ regjsgen@0.6.0 ├─ regjsparser@0.8.4 ├─ repeat-element@1.1.4 ├─ require-directory@2.1.1 ├─ require-main-filename@2.0.0 ├─ resolve-from@3.0.0 ├─ resolve-url@0.2.1 ├─ resolve@1.22.1 ├─ restore-cursor@3.1.0 ├─ ret@0.1.15 ├─ safe-buffer@5.1.2 ├─ scheduler@0.21.0 ├─ semver@6.3.0 ├─ send@0.18.0 ├─ serialize-error@2.1.0 ├─ set-blocking@2.0.0 ├─ set-value@2.0.1 ├─ setprototypeof@1.2.0 ├─ shallow-clone@3.0.1 ├─ shebang-command@1.2.0 ├─ shebang-regex@1.0.0 ├─ shell-quote@1.7.3 ├─ sisteransi@1.0.5 ├─ slash@3.0.0 ├─ slice-ansi@2.1.0 ├─ snapdragon-node@2.1.1 ├─ snapdragon-util@3.0.1 ├─ source-map-resolve@0.5.3 ├─ source-map-support@0.5.21 ├─ source-map-url@0.4.1 ├─ split-string@3.1.0 ├─ sprintf-js@1.0.3 ├─ stackframe@1.3.4 ├─ stacktrace-parser@0.1.10 ├─ static-extend@0.1.2 ├─ string_decoder@1.3.0 ├─ string-width@4.2.3 ├─ strip-eof@1.0.0 ├─ sudo-prompt@9.2.1 ├─ supports-color@7.2.0 ├─ supports-preserve-symlinks-flag@1.0.0 ├─ temp@0.8.4 ├─ throat@5.0.0 ├─ through2@2.0.5 ├─ tmpl@1.0.5 ├─ to-fast-properties@2.0.0 ├─ to-object-path@0.3.0 ├─ to-regex-range@2.1.1 ├─ toidentifier@1.0.1 ├─ tr46@0.0.3 ├─ type-fest@0.7.1 ├─ uglify-es@3.3.9 ├─ unicode-canonical-property-names-ecmascript@2.0.0 ├─ unicode-match-property-ecmascript@2.0.0 ├─ unicode-match-property-value-ecmascript@2.0.0 ├─ unicode-property-aliases-ecmascript@2.0.0 ├─ union-value@1.0.1 ├─ universalify@0.1.2 ├─ unpipe@1.0.0 ├─ unset-value@1.0.0 ├─ update-browserslist-db@1.0.4 ├─ urix@0.1.0 ├─ use-sync-external-store@1.2.0 ├─ use@3.1.1 ├─ util-deprecate@1.0.2 ├─ utils-merge@1.0.1 ├─ vary@1.1.2 ├─ walker@1.0.8 ├─ webidl-conversions@3.0.1 ├─ whatwg-fetch@3.6.2 ├─ whatwg-url@5.0.0 ├─ which-module@2.0.0 ├─ which@1.3.1 ├─ wrap-ansi@6.2.0 ├─ write-file-atomic@2.4.3 ├─ xmlbuilder@9.0.7 ├─ xtend@4.0.2 ├─ y18n@4.0.3 └─ yargs-parser@18.1.3 ✨ Done in 11.06s. /usr/local/lib/node_modules/react-native-cli/index.js:302 cli.init(root, projectName); ^

TypeError: cli.init is not a function at run (/usr/local/lib/node_modules/react-native-cli/index.js:302:7) at createProject (/usr/local/lib/node_modules/react-native-cli/index.js:249:3) at init (/usr/local/lib/node_modules/react-native-cli/index.js:200:5) at Object. (/usr/local/lib/node_modules/react-native-cli/index.js:153:7) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47

image
tuyendv-it commented 2 years ago

You can use --version 0.68.2. [ react-native init MyProject --version 0.68.2 ] It worked for me. Discuss here https://github.com/facebook/react-native/issues/34055

NikitaDudin commented 2 years ago
  1. npm remove -g react-native react-native-cli
  2. npx react-native init AwesomeProjectName
liresky commented 2 years ago
npm remove -g react-native react-native-cli
npx react-native init AwesomeProjectName

not ok.

liresky commented 2 years ago

You can use --version 0.68.2. [ react-native init MyProject --version 0.68.2 ] It worked for me. Discuss here #34055

yes 0.68.2 is ok. close this.

satheeshwaran commented 1 year ago

I had this issue with react-native@0.71.8 too.

Removed global react-native and react-native-cli packages. Used --version in init (npx react-native init project --version 0.71.8)

Both did not work, then I looked at the RN documentation that says this.

npx react-native@X.XX.X init AwesomeProject --version X.XX.X

So I tried

npx react-native@0.71.8 init AwesomeProject --version 0.71.8

and it worked. Hope it helps someone.