Error installing React from "getting started" tutorial - ios

I've tried install React Native from "Getting Started". When I run the command:
react-native init AwesomeProject
I got this error, and the application didn't lunch in the simulator.
~/tmp/react-native/AwesomeProject/node_modules/react-native/packager ~
/Users/david/tmp/react-native/AwesomeProject/node_modules/react-native/local-cli/server/formatBanner.js:48
chalkFunction: (fn) => fn,
^^
SyntaxError: Unexpected token =>
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/david/tmp/react-native/AwesomeProject/node_modules/react-native/local-cli/server/checkNodeVersion.js:12:20)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
~ Process terminated. Press <enter> to close the window
My system information:
Mac OS 10.11.6
node: stable 6.3.0 (bottled), HEAD
watchman: stable 4.6.0 (bottled), HEAD
XCode 7.3.1
Thanks for advance

I'd installed node 6.3.0 from brew command. But the current node version was 0.12.7 I fixed this by doing the following:
brew uninstall node --force
brew install node
(optional, if you don't have nvm) brew install nvm
only if you have installed nvm from brew (step 3) you must read the output brew command
nvm install v6.3.0
nvm alias default 6.3.0
After that I was able to compile and run

Related

yo #microsoft/sharepoint fails on TypeError: lookups.flatMap is not a function

After installation of Node v10.16.1 and installation of gulp and yo (Everything looks alright !) it fails on command yo #microsoft/sharepoint with TypeError: lookups.flatMap is not a function
C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70
filePatterns: lookups.flatMap(prefix => [`${prefix}/*/index.ts`, `${prefix}/*/index.js`]),
^
TypeError: lookups.flatMap is not a function
at Environment.resolver.lookup (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70:27)
at init (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:130:7)
at pre (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:89:3)
at Object.<anonymous> (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:219:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
I am a beginner ! Few days ago it worked , then I installed nvm (following a microsoft instruction to swap node v8 to node v10) and then problems started and i uninstalled nvm, node v8 and v10 en reinstalled node v10. The TypeError returns. Perhaps something to do with path ?
Any idea ? thx
I resolved this by downgrading my gulp and yeoman versions.
First checked to see what I had installed:
npm list -g --depth=0
Output:
+-- #microsoft/generator-sharepoint#1.11.0
+-- gulp#4.0.2
+-- npm#6.14.12
+-- windows-build-tools#5.2.2
-- yo#4.0.0
So I uninstalled both gulp and yeoman:
npm uninstall -g gulp
npm uninstall -g yo
Then installed older versions:
npm install -g gulp#3.9.1
npm install -g yo#3.1.0
Then was able to generate the SharePoint framework project successfully after running:
yo #microsoft/sharepoint
Once it completed, I was able to run the following from inside the SharePoint framework project directory to launch the local workbench:
gulp serve
Note: If if not already done so once, you need to generate a development certificate inside the SharePoint framework project directory:
gulp trust-dev-cert
I believe you should upgrade node.js to v14, as stated in Microsoft official guide:
Install the latest version of Node.js LTS v14.
This version is the currently recommended version of Node.js to use with the SharePoint Framework
Node v10 is EOL in few days (tomorrow, in fact), so it is unsafe to use it.
I faced the same issue today while scaffolding a new webpart, and I solved by upgrading node from v10 to v14.
Another suggestion is to avoid installing global npm packages if you are going to use it just once (for scaffolding, for example); I usually use npx to download on the fly yo and the microsoft generator, so I always use the latest available versions:
$ npx -p yo -p #microsoft/generator-sharepoint -c "yo #microsoft/sharepoint"
Hope this can help, bye!
First try to uninstall both gulp and yeoman:
to uninstall run these commands-->
npm uninstall -g gulp
npm uninstall -g yo
Then installed older versions:
to install run these commands-->
npm install -g gulp#3.9.1
npm install -g yo#3.1.0
Then was able to generate the SharePoint framework project successfully after running:
yo #microsoft/sharepoint
Check version list if same or not:
npm list -g --depth=0
+-- #microsoft/generator-sharepoint#1.11.0
+-- gulp#3.9.1
+-- gulp-cli#2.3.0
+-- yarn#1.22.17
+-- yo#3.1.0
Run below commands to uninstall:
npm uninstall -g gulp
npm uninstall -g yo
Run below commands:
npm install -g gulp#3.9.1
npm install -g yo#3.1.0
npm uninstall -g #microsoft/generator-sharepoint
Then install a previous version:
npm install -g #microsoft/generator-sharepoint#1.11.0

React-native Error : Failed to install CocoaPods dependencies for iOS project, which is required by this template

I tried to create a project through npx, but an error occurred.
$ npx react-native init springtesting
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./springtesting/ios && pod install".
So I executed a sentence inside the ios folder in the project.
$ pod install
[!] Invalid `Podfile` file: [!] /usr/local/bin/node -e console.log(require('#react-native-community/cli').bin);
internal/modules/cjs/loader.js:983
throw err;
^
Error: Cannot find module '#react-native-community/cli'
Require stack:
- /Users/myname/springtesting/ios/[eval]
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at [eval]:1:13
at Script.runInThisContext (vm.js:120:20)
at Object.runInThisContext (vm.js:311:38)
at Object.<anonymous> ([eval]-wrapper:10:26)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at evalScript (internal/process/execution.js:94:25) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/User/myname/springtesting/ios/[eval]' ]
}
.
# from /Users/taehong/springtesting/ios/Podfile:42
# -------------------------------------------
#
> use_native_modules!
# end
# -------------------------------------------
Pod version
$ pod --version
1.8.4
What's the problem?
And then i deleted the phrase 'use_native_modules' and it became normal.
Your error clearly states #react-native-community/cli is missing install it globally using
npm i -g #react-native-community/cli
If still it throws the same error update the cocoapods using
brew upgrade cocoapods
run this:
xcode-select -p
if you do not get this path : Xcode.app/Contents/Developer
then run this command
sudo xcode-select --switch /Applications/Xcode.app
create again new project
Good to go..
Your question shows that you didn't install
#react-native-community/cli
Solution 1 : run this command
npm i #react-native-community/cli
update the cocoapods
Solution 2:
npm start -- --reset-cache

why is cocoapods dependency installed failed when creating a react native app?

I am a fresh man for using react native. And I am following the get started of react native on my Mac. When I use npx react-native init AwesomeProject to create a new app, then I get a result shows me:
✔ Downloading template
✔ Copying template
✔ Processing template
⠋ Installing CocoaPods dependencies (this may take a few minutes)
[!] Invalid `Podfile` file: [!] /usr/local/bin/node -e console.log(require('#react-native-community/cli').bin);
internal/modules/cjs/loader.js:796
throw err;
^
Error: Cannot find module '#react-native-community/cli'
Require stack:
- /Users/rionay/Desktop/react-native/AwesomeProject/ios/[eval]
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at [eval]:1:13
at Script.runInThisContext (vm.js:116:20)
at Object.runInThisContext (vm.js:306:38)
at Object.<anonymous> ([eval]-wrapper:9:26)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at evalScript (internal/process/execution.js:80:25) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/rionay/Desktop/react-native/AwesomeProject/ios/[eval]' ]
}
.
# from /Users/rionay/Desktop/react-native/AwesomeProject/ios/Podfile:42
# -------------------------------------------
#
> use_native_modules!
# end
# -------------------------------------------
✖ Installing CocoaPods dependencies (this may take a few minutes)
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./AwesomeProject/ios && pod install".
CocoaPods documentation: https://cocoapods.org/
But I have installed CocoaPods by sudo gem install cocoapods, and it shows me:
Successfully installed cocoapods-1.8.4
Parsing documentation for cocoapods-1.8.4
Done installing documentation for cocoapods after 3 seconds
1 gem installed
So What's the problem? How can I fix it? Thank you very much!
It's a bug, had the same problem this morning. I fixed it by doing
npm i #react-native-community-cli
After that i went in the ios folder and could do pod install succesfully

Problems installing applesimutils using Homebrew

When trying to run the following commands:
brew tap wix/brew
brew install applesimutils
my homebrew fails with the following:
Warning: Some installed formulae are not readable:
applesimutils: /usr/local/Homebrew/Library/Taps/wix/homebrew-brew/applesimutils.rb:4: syntax error, unexpected <<, expecting keyword_end
<<<<<<< HEAD
^
/usr/local/Homebrew/Library/Taps/wix/homebrew-brew/applesimutils.rb:17: syntax error, unexpected ===, expecting keyword_end
=======
^
/usr/local/Homebrew/Library/Taps/wix/homebrew-brew/applesimutils.rb:23: syntax error, unexpected >>, expecting keyword_end
>>>>>>> Detox Instruments 1.10.10110
^
/usr/local/Homebrew/Library/Taps/wix/homebrew-brew/applesimutils.rb:23: unexpected fraction part after numeric literal
>>>>>>> Detox Instruments 1.10.10110
I'm running on
Environment:
OS: macOS 10.14.5
Node: 10.15.3
Yarn: 1.16.0
npm: 6.4.1
Watchman: 4.9.0
Xcode: Xcode 10.2.1 Build version 10E1001
Android Studio: 3.4 AI-183.5429.30.34.5452501
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: ^0.55.4 => 0.55.4
I tried to do brew doctor and brew cleanup but still getting the same error.
Thanks
This has nothing to do with Detox.
The solution for this issue is explained in the AppleSimUtils readme's troubleshooting section:
If Homebrew complains about a conflict in the wix/brew tap, run brew untap wix/brew && brew tap wix/brew and try installing again

Yeoman error when running yo webapp

Running the latest of npm and node and I've checked to make sure their ownership privileges are correct, any ideas?
TypeError: Cannot read property 'bold' of undefined
at Object.<anonymous> (/usr/local/lib/node_modules/generator-webapp/node_modules/yeoman-generator/lib/util/common.js:5:56)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/generator-webapp/node_modules/yeoman-generator/lib/base.js:101:26)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
Had the same issue. What solved it for me was manually updating yeoman-generator. For this I edited package.json in /usr/lib/node_modules/generator-webapp/ and changed the version of yeoman-generator to 0.13.2 and ran npm install in the directory after that.
The git repository of generator-webapp is already using the latest yeoman-generator version but you have to wait for a new release I guess.
A few days ago a new version of node has been released, you need to update node and then update each package.
Update node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
node -v
then update your packages
sudo npm update -g
cd myYoproject
npm update
Your node package was not fully installed.
Try
npm update generator-webapp -g
I got the same issue, the only thing I changed it was to update NodeJS to version 0.10.17, but I dunno...

Resources