MapBox SDK for React Native Installation shows Error - javascript

I created a React Native project with Expo using expo init MapTry. I am currently trying to install MapBox library into it. For some reason I get an error at the first step after trying to install it. I followed this guide of installation: https://github.com/rnmapbox/maps#Installation but for some reason I am getting an error message when I try to run npm install rnmapbox/maps#main --save from the terminal. The error says the following:
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent An unknown git error occurred
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
I also tried to search for it in the official NPM site and found this one: https://www.npmjs.com/package/#rnmapbox/maps . After running the following code: npm i #rnmapbox/maps which was written there, I get the same error message as written above. What should I do? How can I use MapBox library in React Native?

try to run this command in your terminal
with NPM
npm install #rnmapbox/maps --save
with YARN
yarn add #rnmapbox/maps

Related

I encountered a problem when installing Next JS

I was installing NextJS when I encountered the following error:
D:\Codes\React\Learn>npx create-next-app
npm WARN using --force Recommended protections disabled.
npm WARN using --force Recommended protections disabled.
npm ERR! code E404
npm ERR! 404 File Not Found - GET https://skimdb.npmjs.com/registry/create-next-app
npm ERR! 404
npm ERR! 404 'create-next-app#latest' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Local\npm-cache\_logs\2023-02-06T12_41_40_938Z-debug-0.log
Can anyone help me?
I wanted to work with NextJS......but I encountered this error!
You should give directory address in the installation command ,
Try : npx create-next-app#latest . if you want to install the packages in current directory or
npx create-next-app#latest YOUR_FOLDER_NAME and packages will be installed in new folder with the given name as YOUR_FOLDER_NAME.
Try this:
npm i -g create-next-app
It will install create next app globally. To create a next app run this command, if you want to install in current folder.
npx create-next-app
Otherwise, specify the folder name like,
npx create-next-app [your app name]

Error when starting new React Native Project

I'm following the setup instructions from the React Native Documentation page, on my M1 Macbook Pro. I have previously worked on React projects and was able to create and run React Native Expo projects previously on the same machine.
I followed the instructions to the letter, but when I arrived at the 'Create A New Application" section, using the npx react-native init AwesomeProject command, the new project creation failed. Here are the error message outputted on the Terminal:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: undefined#undefined
npm ERR! Found: react-native#0.66.4
npm ERR! node_modules/react-native
npm ERR! peer react-native#"*" from #react-native-community/cli#6.3.1
npm ERR! node_modules/#react-native-community/cli
npm ERR! #react-native-community/cli#"^6.0.0" from react-native#0.66.4
npm ERR! react-native#"0.69.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! react-native#"0.69.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#18.0.0
npm ERR! node_modules/react
npm ERR! peer react#"18.0.0" from react-native#0.69.2
npm ERR! node_modules/react-native
npm ERR! react-native#"0.69.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I tried to uninstall react-native and install it back but couldn't find a proper instruction on the net to do that. How can I just scrape the previously installed react-native (judging from the error message, i got RN#0.66.4, when I want to use the latest RN) and install a fresh, latest react native?
if you are on Mac and your node version is 18.. which Is latest but not greatest.. you need to download 16.. the stable one.
Step-1
brew uninstall node;
# or `brew uninstall --force node` which removes all versions
brew cleanup;
rm -f /usr/local/bin/npm /usr/local/lib/dtrace/node.d;
rm -rf ~/.npm;
Step 2 - and install it from node site by downloading the binary
Step 3 - just check the node version again if you have 16..
then you can try creating the react native project once again.
Please let us know if it worked for you. Wish you luck!!
In addition to what the answer suggests, you can do brew install node#16 to install this particular version instead of manually downloading the binary.
If installing node version 16 doesn't work for you ensure you update npm by running sudo npm update -g.

react-native:Unable to import react-native after installing through npm

I am in my initial stages of learning react and have a limited understanding of npm manager and importing libraries into project.
For my current project, I had installed react-native using
npm install react-native
This also reflects in my package.json and node_modules folder
"react-native": "^0.61.5"
Now, when I try to import react-native as follows into AppCarousel.js
import React from 'react';
import {Dimensions} from 'react-native';
and then build the application , i get the following error message
.\src\Components\AppCarousel.js
Cannot find module: 'react-native'. Make sure this package is installed.
You can install this package by running: npm install react-native.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react#1.0.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\{USER}\AppData\Roaming\npm-cache\_logs\2020-01-09T13_08_54_364Z-debug.log
The terminal process terminated with exit code: 1
I tried referring to the the following questions i) link1 ii)link2
I cannot make out if this is a bug in npm or if there is a lack of understanding for installing packages on my side. Any help will be appreciated, thanks.
Terminal to kill the process:
ps -ax | grep npm
Then try to navigate to your directory in your terminal and try to do write this:
npm I react
or again:
npm i react-native
Simple explanation to get in use with TypeScript and React:
https://facebook.github.io/react-native/docs/typescript

Command not found

Been struggling to get my first vue project started and was looking for some help.
I have both npm and node updated on my system but continually keep falling to the same issue.
My steps:
1.) npm install
Terminal Response:
npm WARN mbasile#1.0.0 No description
up to date in 0.095s
2.) npm install vue
Terminal Response:
npm WARN mbasile#1.0.0 No description
+ vue#2.5.16
updated 1 package in 0.951s
Here's where things get funky?
3.) npm install -g #vue/cli
Terminal Response:
npm ERR! path /Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin'
npm ERR! { Error: EACCES: permission denied, rmdir '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin'
npm ERR! cause:
npm ERR! { Error: EACCES: permission denied, rmdir '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin' },
npm ERR! stack: 'Error: EACCES: permission denied, rmdir '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mbasile/.npm/_logs/2018-05-09T17_53_06_030Z-debug.log
So given this response I run
4.) sudo npm install -g #vue/cli
Terminal Response:
/Users/mbasile/.npm-global/bin/vue -> /Users/mbasile/.npm-global/lib/node_modules//bin/vue.js
+ #3.0.0-beta.9
updated 1 package in 6.597s
5.) vue create vue-project
Terminal Response:
-bash: vue: command not found
Leaving me a bit puzzled and confused here, but any help/response would be appreciated.
I had this problem too and it was a little bit tricky to find a solution so I'll describe all the steps that helped me find a solution.
It's resolving a general problem with the wrong path for global packages in npm or missing path in shell variable $PATH.
Fix for macOS Mojave but should work on all UNIX systems
First of all, after installing the package globally npm will show you where a new package is installed.
$ npm i -g #vue/cli
/usr/local/Cellar/node/9.5.0/bin/vue -> /usr/local/Cellar/node/9.5.0/lib/node_modules/#vue/cli/bin/vue.js
We can also check it in the npm config.
$ npm config get prefix
/usr/local/Cellar/node/9.5.0
So if after the global installation your terminal couldn't recognize the command it's probably missing in your shell variable $PATH. You can easily check it.
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
As we can see, the path from npm config isn't present in the shell variable $PATH.
Now we have two options to fix it.
1. First option - change npm config.
$ npm config set prefix '/usr/local'
$ npm config get prefix
/usr/local
After we changed the path in the config we will have to reinstall the desired package.
$ npm i -g #vue/cli
2. Second option - add path from npm config to shell $PATH
$ export PATH=$PATH:/usr/local/Cellar/node/9.5.0
In this case, we don't need to install the package again.
Regardless of the selected option, we can now control if everything works.
$ vue --version
3.0.5
Maybe it is something wrong with npm
I recommend you,first list all global npm packages to see if vue is installed with the command: npm list -g --depth=0
Then if vue is installed but again you get error try to delete vue with the command: npm uninstall -g nameOfPackage
Finally do it again from scratch: npm install -g #vue/cli and to create new project,navigate to directory you want to create the project and execute: vue create nameOfProject
What are you trying to do?
npm install -g #vue/cli
This is the command you should run on terminal to globally (-g) install vue command line interface.
After that you can do vue create vue-project

Why won't my React Native app run on my device

I want to be able to test my app on Expo (an IPhone app used to test React Native code after you hit save) and I just can't seem to get past this error I'm getting Terminal. I've ran my app using Expo before with no problems but now after trying to include a Navigator in my app, I get an error.
First I did this:
$ npm i -g create-react-native-app
$ create-react-native-app my-project
$ cd my-project`
Then I wanted to include a Navigator in my app so I went ahead and did this:
npm install --save react-navigation
After that, in order to get Expo running I did:
npm start
When I do npm start, I get this error in Terminal:
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! Mestro#0.1.0 start: `react-native-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the Mestro#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
my guess would be that you are using npm5, I would recommend using npm4, npm5 is currently (as of june 17, 2017) very buggy. see this recommendation in the README.

Categories

Resources