how to run an existing project of react native - javascript

I wanted to download and run someone else's project in order to consider its functions. I ran into a number of problems ... that it does not deign to start, and I just don’t know what to do, help, please
https://github.com/sunlight3d/react_native_v0.49/tree/master/61-Realm%20React%20Native%235.Filter%20data%20and%20working%20with%20To-Many%20Relationships/code/tutorialProject
1) copied to the working folder tutorial project
2) opened VS code
3) went into the working folder and clicked open in cmd folder tutorial project
4) then I enter react-native run-android
and get fiasco
d:\JS\tutorialProject>react-native init tutorialProject
internal/modules/cjs/loader.js:657 throw err; ^
Error: Cannot find module 'graceful-fs' at
Function.Module._resolveFilename
(internal/modules/cjs/loader.js:655:15) at Function.Module._load
(internal/modules/cjs/loader.js:580:25) at Module.require
(internal/modules/cjs/loader.js:711:19) at require
(internal/modules/cjs/helpers.js:14:16) at Object.<anonymous>
(d:\JS\tutorialProject\node_modules\react-native\local-cli\cli.js:12:1)
at Module._compile (internal/modules/cjs/loader.js:805:30) at
Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10)
at Module.load (internal/modules/cjs/loader.js:672:32) at
tryModuleLoad (internal/modules/cjs/loader.js:612:12) at
Function.Module._load (internal/modules/cjs/loader.js:604:3)
I started googling and found something to do with some dependencies. Using react-native init MyProject
5) react-native init tutorialProject and getting the tighter right line
I try to start the server through npm and then it's funny ...
6) npm-intall
d:\JS\tutorialProject>npm install npm WARN deprecated core-js#1.2.7:
core-js#<2.6.5 is no longer maintained. Please, upgrade to core-js#3
or at least to actual version of core-js#2. npm WARN deprecated
connect#2.30.2: connect 2.x series is deprecated npm ERR! path
d:\JS\tutorialProject\node_modules\.bin\react-native npm ERR! code
EEXIST npm ERR! Refusing to delete
d:\JS\tutorialProject\node_modules\.bin\react-native: is outside
d:\JS\tutorialProject\node_modules\react-native and not a link npm
ERR! File exists: d:\JS\tutorialProject\node_modules\.bin\react-native
npm ERR! Move it away, and try again.
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\Nick\AppData\Roaming\npm-cache\_logs\2019-04-16T18_15_13_614Z-debug.log
and here I am absolutely don't know. How to run someone else's project?

When you download after you need to install all package in package.json
npm install --save
then you need to start another terminal
npm start -- --reset-cache / npm start / react-native start
It's for starting your bundler
finally you can run your project
react-native run-android

From a computer with node install, you navigate a command line to the root of the project folder.
Then you install dependencies:
npm i
This installs all the libraries the project needs to build
Then you run the projects build script. This is defined in the projects package.json file. In that projects case, the script is called start. So:
npm run start

all dependencies and plugins have configured in package.json file. so you need to install:
npm install
then, you can start
react-native run-android
or
npm run start

if you already have a bundle app (android or ios ...)
react-native run-android / react-native run-ios
else you should run
react-native start
and then run :
react-native run-android (or ios)

This is the answer when you compile on windows and android studio
1.Open cmd(as an admin)
2. Npm install
3. Wait for build gradle in Android studio done compiling
4. Run on cmd react-native android-run
Sometimes you may get this error (refer image below)
This is a failure to build because of gradle error. To solve this, you may try to delete the files/folder in the error message and run again react-native android-run.

Just run
npm cache clean --force
npm i or npm install

Install Chocolatey
Chocolatey is a popular package manager for Windows. So at first, we need to install it on our system.
To install Chocolaty, Open Command Prompt with administrator privileges and run the command below.
#"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
choco install -y nodejs.install python2 jdk8.
npm install –g react-native-cli
More Detail Follow this
Path in user variable upper section

Related

Error: You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1)

As the title says, I cannot run create-react-app.
You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
Doing this does not change the error. npm uninstall -g create-react-app
I entered this command to try it out and got a message that the tar was out of date.
npm install -g create-react-app
npm WARN deprecated tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code EEXIST
npm ERR! path /opt/homebrew/bin/create-react-app
npm ERR! EEXIST: file already exists
npm ERR! File exists: /opt/homebrew/bin/create-react-app
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
https://www.npmjs.com/package/tar
I ran the command with this reference.
However, the tar was not updated.
I have already tried all the published solutions, but they don't work. Can someone please help me? Please.
I tried clearing the cache but could not solve the problem.
npx clear-npx-cache
Need to install the following packages:
clear-npx-cache
Ok to proceed? (y) y
I was able to successfully run the following command by specifying the version each time, but it is a hassle and I want to be able to run it normally.
npx create-react-app#latest my-app
The "fish" shell I am currently using is node v18.0.0, so I downgraded to v16.15.0 and it works fine.
fisher install jorgebucaran/nvm.fish
nvm install v16
I had forgotten to lower the node version in fish because it had been working fine with zsh.

issue when running npm run serve in vue project

I've got an issue when try running server for vue project
this is the issue
ERROR Error: No valid exports main found for
' PROJECT PATH\node_modules\colorette'
Error: No valid exports main found for
'PROJECT PATH\node_modules\colorette'
at resolveExportsTarget (internal/modules/cjs/loader.js:622:9)
at applyExports (internal/modules/cjs/loader.js:499:14)
at resolveExports (internal/modules/cjs/loader.js:548:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:654:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:953:27)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Module.require (internal/modules/cjs/loader.js:1028:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (C:\Users\AlaaMohammed\PhpstormProjects\vue-2\node_modules\autoprefixer\lib\autoprefixer.js:5:17)
at Module._compile (internal/modules/cjs/loader.js:1139:30) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! vue-2#0.1.0 serve:
vue-cli-service serve npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the vue-2#0.1.0 serve script. npm ERR! This is probably not
a problem with npm. There is likely additional logging output above.
I want some to response to my problem
try to reinstall the colerette plugin version 1.2.0 manually
npm i colorette#1.2.0
Upgrade node to version 14.5 will resolve this issue.
I did the following and it worked:
1)_ First i checked the versions
npm outdated
npm update
npm install
npx npm-check-updates - u
2)_ Once i was 100% sure the problems didn't come from that source, i typed the following:
npm install autoprefixer#9.8.0
and it solved the problem.
Note: try to "npm start" before you connect the scss to the App, just to see if you can visualize something (like: hello world) in the browser, if everything is fine, create the folder scss with the main.scss inside of it, import it and then try the steps.
My node -v: v16.1.0
What worked for me npm ci
Updating the node version can solve your problem.

Gatsby - Command failed with exit code 1: npm install

I'm trying to start my first Gatsby project but keep encountering the same error when creating a new project.
After running gatsby new project-1, I get the following error:
npm ERR! Maximum call stack size exceeded
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/tom.allen/.npm/_logs/2020-06-18T15_54_40_537Z-debug.log
ERROR
Command failed with exit code 1: npm install
Error: Command failed with exit code 1: npm install
- error.js:56 makeError
[lib]/[gatsby-cli]/[execa]/lib/error.js:56:11
- index.js:114 handlePromise
[lib]/[gatsby-cli]/[execa]/index.js:114:26
- task_queues.js:97 processTicksAndRejections
internal/process/task_queues.js:97:5
- init-starter.js:139 async install
[lib]/[gatsby-cli]/lib/init-starter.js:139:7
- init-starter.js:206 async clone
[lib]/[gatsby-cli]/lib/init-starter.js:206:3
- init-starter.js:345 async initStarter
[lib]/[gatsby-cli]/lib/init-starter.js:345:19
- create-cli.js:400
[lib]/[gatsby-cli]/lib/create-cli.js:400:7
I have tried deleting the node_modules inside the project folder and running npm i again but I can't work out how to fix this issue. I'm on node v12.17.0 if that makes a difference... Any help will be really appreciated!
Install nvm
We strongly recommend using a Node version manager like nvm to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.
npm's docs
If you have installed Node via some package manager or some Node installer, first of all, uninstall it and instead install Node from nvm. In my case I had installed Node via NodeSource, so:
sudo apt purge node
Go ahead and install nvm, following the instructions on the Github repo. I had to include the shell script manually in my ~/.zshrc because the nvm script didn't do.
Install node and npm via nvm
Run the following to install Node and npm: nvm install node
Now, in order to make gatsby new works, you will need to install a previous version of node, which will be: v14.13.1. Run the following command and you will install the mentioned version:
nvm install 14.13.1
Select the Node version to use if is not selected:
nvm exec 14.13.1 node --version
Gatsby
Now, you only need to install Gatsby CLI, and then simply use it.
Run the following: npm install -g gatsby-cli
Go to the folder where you want to create your project and then run:
gatsby new [your-project-name] https://github.com/thomaswangio/gatsby-personal-starter-blog
So there's a few suggestions:
Hard cache removal: npm cache clean --force
Upgrade gatsby-cli version: npm update
Delete node_modules and .cache folder
Keep in mind removing package-lock.jsonto unlock you dependencies.

npm install couldnt install angularjs libraries

I have installed mean.io and ran sudo npm install. Actually following commands in sequence
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
sudo npm install
It is supposed to download and install angularjs libraries into public/system/lib. After doing the above steps public /system/lib is not created due to which when I start the application I get the error
events.js:72
throw er; // Unhandled 'error' event
^
Error: ENOENT, open '/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp/public/system/lib/bootstrap/dist/css/bootstrap.css'
[nodemon] app crashed - waiting for file changes before starting...
Is it something to do with certain npm/angularjs server being down. I have faced this problem earlier also but got fixed on 2nd try and I didn't bother to do more research. This became a big issue when I try to pull my repo into cloud and start the application. public/system/lib is added in .gitignore by default and is expected to be created during npm install.
I get following warnings with sudo npm install
npm WARN package.json mean-connect-mongo#0.4.3 No repository field.
npm WARN cannot run in wd mean#0.3.3 node node_modules/bower/bin/bower install (wd=/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp)
this is link to package.json
The problem maybe related to running npm install as sudo, which can cause problems. As mentioned in another stack overflow question, this can be worked around in a couple ways. But because it looks like this is being run from your home directory, you really shouldn't need to run npm install as root.
Try to issue the same commands, but the last without sudo:
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
npm install
Note that the reason you may need to run npm install -g <package> using sudo is because by default npm uses /usr/local for global installs, which can be a restricted directory. However, when you install a package locally (without the -g flag) you should not need to run as root.

How do I use Node.js modules?

I recently installed Node.js on a fresh Linode box, and I think I'm in a weird situation where I can't use require() to load any third party modules.
I've installed npm and have successfully installed modules via npm, but whenever I try to require one of the modules (or just some of my own code in the same directory), Node.js throws an error saying it can't find the module.
Any thoughts as to why this might be happening?
Here's an example error message:
root#li200-141:/home/mike# npm install sequelize
npm ERR! sudon't!
npm ERR! sudon't! Running npm as root is not recommended!
npm ERR! sudon't! Seriously, don't do this!
npm ERR! sudon't!
npm info it worked if it ends with ok
npm info version 0.2.2
npm info fetch http://registry.npmjs.org/sequelize/-/sequelize#0.4.2.tgz
npm info install sequelize#0.4.2
npm info activate sequelize#0.4.2
npm info build Success: sequelize#0.4.2
npm ok
root#li200-141:/home/mike# node
> var n = require('sequelize').Sequelize
Error: No such native module sequelize
at requireNative (node.js:83:32)
at cwdRequire (repl:27:10)
at [object Context]:1:9
at Interface.<anonymous> (repl:96:19)
at Interface.emit (events:27:15)
at Interface._ttyWrite (readline:295:12)
at Interface.write (readline:132:30)
at Stream.<anonymous> (repl:77:9)
at Stream.emit (events:27:15)
at IOWatcher.callback (net:489:16)
Apparently, there is a bug in node v0.2.2 that prevents require from working properly from the REPL.
Try putting your code in a .js file instead. That worked for me.

Categories

Resources