expo init <project name> throwing npm ERROR (windows OS) - javascript

Just started with expo and React-Native and when I run
expo init ProjectName
I am getting an error stating:
Unexpected end of JSON input while parsing near '...,"version":"7.0.0-bet'
Process exited with non-zero code: 1
Set EXPO_DEBUG=true in your env to view the stack trace.
When I add the said thing in env (using set EXPO_DEBUG=true on windows), I get the following error:
Error: Process exited with non-zero code: 1
at ChildProcess.child.on (C:\Users\mohit\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\spawn-async\build\spawnAsync.js:39:21)
at ChildProcess.emit (events.js:182:13)
at ChildProcess.cp.emit (C:\Users\mohit\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.js:40:29)
at maybeClose (internal/child_process.js:962:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
It's something related to 'spawn-async'. I was also getting issues with 'spawn' sometime earlier while creating a node-server...but I resolved that there and then using 'exec' instead. Tried to find this on expo forums and even in react-native issues but couldn't find a solution. Can someone plz suggest something? Is it some "windows" thing only or something related to npm releases?
P.S: I also ran create-react-native-app ProjectName and again got a similar kind of error about end of JSON input!

Now I know what can be the issue, it can be just the trivial one:
Please update node an npm to the newest available version and please init you project again in different directory.

You'll need to have Node.js (version 10 or newer) installed on
your computer. Download the latest version of Node.js.
Additionally, you'll need Git to create new projects with Expo
CLI. You can download Git from here.
Make sure that you have installed these two things in your device.
Go to doc for expo installation

in my case. make sure you have yarn installed and update tour android studio packages, for it to work

Related

React Native, Failed to launch emulator. Reason: No emulators found as an output

I'm trying to run my react native app in emulator by using command react-native run-android but it's throwing that error
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 44s
info Connecting to the development server...
warn Failed to connect to development server using "adb reverse": spawnSync /Opt/Android/platform-tools/adb ENOENT
info Starting the app...
The system cannot find the path specified.
error Failed to start the app. Run CLI with --verbose flag for more details.
Error: Command failed: /Opt/Android/platform-tools/adb shell am start -n com.reactproject/com.reactproject.MainActivity
at makeError (C:\Users\Danger World\ReactProject\node_modules\execa\index.js:174:9)
I already setup my android studio and sdk manager, avd manager like it's shown in doc also I already set path but it's still showing that error, anyone know why? Can anyone help please?
You can fix it by using the command :
react-native doctor
This command shows all issues that need to be fixed.
Press f to fix the issues and don't forget to restart your windows
And after then open the emulator before running your project.
Once emulator opened,
run command:
react-native run-android
After fixed:
Don't forget to give me an upvote if that's work.
In My Case, I have to re-run the command in the same terminal where you are trying to run npx react-native run-android
Step 1. paste the source command first
source ~/.bash_profile OR source ~/.bashrc
Step 2. RUN Next command
npx react-native run-android
set your AVD manager path and JDK path like this , also you have to add Android Home path

How Can I run react-native app in my mobile because avd is too slow

Please help me. My React Native app is not running in my mobile. It works fine on the android simulator, but the performance is quiet bad.
The error is:
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier"
flag.
Jetifier found 967 file(s) to forward-jetify. Using 2 workers...
info Starting JS server...
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more
log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
error Failed to install the app. Make sure you have the Android development environment set up:
https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Com
mand failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
This might be because lower version of Jdk. Please update JDK version supported by Android Studio
For Reff : Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
Try React Native environment to upgrade your environment because there is a thread in here Grovy Error
It's simple , just connect your mobile with Android studio and on the developing mode , then select the device from Android studio and run the project the app will simply open on your phone , unless you don't have any errors in enviornment.

vscode-ripgrep not getting installed in VSCode build/run process

I was trying to build and run VSCode on my Ubuntu 17.10 using the following guide: https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run
When I tried to install dependencies using yarn, it is giving me the following error:
error /home/dhairyakhale/git/vscode/node_modules/vscode-ripgrep: Command failed.
Exit code: 1
Command: node ./lib/postinstall.js
Arguments:
Directory: /home/dhairyakhale/git/vscode/node_modules/vscode-ripgrep
Output:
Unzipping to /home/dhairyakhale/git/vscode/node_modules/vscode-ripgrep/bin
And then it stops the process. How do I proceed?
I have a similar issue while installing Theia. The broken vscode-ripgrep installation caused it. Here is the ticket I submitted to vscode-ripgrep.
https://github.com/roblourens/vscode-ripgrep/issues/15

All npm commands giving same error (ENOENT)

I'm using windows 8.1 x64 with all updates.
I was using nodejs 8.9.1 - I took an error on command "npm -v".
So I uninstalled this version and install 8.9.3. It gave me same error on the command.
And then I uninstalled 8.9.3 and clean all paths using this answer;
https://stackoverflow.com/a/20711410/1143249
Then installed new version 9.3.0...
But still, I'm getting same error in all npm commands.
What am I missing? How can I solve this problem?
C:\Users\UserName\Desktop>npm -v
Error: spawn C:\Program Files\nodejs\node.exe ENOENT
at _errnoException (util.js:999:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
at onErrorNT (internal/child_process.js:389:16)
at process._tickCallback (internal/process/next_tick.js:152:19)
at Function.Module.runMain (module.js:703:11)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:618:3
C:\Program Files\nodejs\node_modules\npm\lib\npm.js:51
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.get (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:51:13)
at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at process.emit (events.js:159:13)
at process._fatalException (bootstrap_node.js:387:26)
5.5.1
events.js:136
throw er; // Unhandled 'error' event
^
Error: spawn C:\Program Files\nodejs\node.exe ENOENT
at _errnoException (util.js:999:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
at onErrorNT (internal/child_process.js:389:16)
at process._tickCallback (internal/process/next_tick.js:152:19)
at Function.Module.runMain (module.js:703:11)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:618:3
Update:
Everytime I uninstalled nodejs, clean/delete folders and tried these versions;
- node-v9.3.0-x64 not working
- node-v8.9.3-x64 not working
- node-v8.9.1-x64 not working
- node-v8.9.0-x64 not working
- node-v7.10.0-x64 shows version number also a small error.
Here is the output;
C:\Users\UserName\Desktop>npm -v
5.6.0
events.js:163
throw er; // Unhandled 'error' event
^
Error: spawn C:\Program Files\nodejs\node.exe ENOENT
at exports._errnoException (util.js:1050:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:607:11)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3
Update:
I uninstalled Avg anti-virus protection and installed node-v6.12.3-x64.msi. Still I have problems, an example; I can't run commands like;
Last Update
Thanks for all answers ( until this date: 10.02.2018 03:30 PM GTM+3 )
( I've completed some of my jobs with vm windows until this date but now I've sad news.)
I ran out all options and I have still a lot work to do with npm packages.
So, I've formatted my machine and replace with Windows 10 Enterprise x64.
I can't try new answers now but here is golden point what I've learned;
If you have mission critical machine like ci-build (jenkins etc.) or
if you don't have more than one computer (And vm is not an option)
Just backup your drive completely at time to time because you will never know
your computer softwares (like node - npm) could give an interesting errors such as this. That's what I learned, just saying...
The workaround is to ensure that C:\Users\{user}\AppData\Roaming\npm exists and is writable with your normal user account.
see Troubleshooting
Although haven't tested Node on Windows 8, I suggest you get rid of npm installation under AppData folder altogether. You can achieve this by using a Node version manager. I recommend Nodist. You can easily switch between versions as well.
With Nodist you can run the command as such:
nodist 6.2.10
One of the things I suspect is Node runtime's limited access to required files under C:/ drive - maybe something related to Windows 8. That said, you could install nodist in any drive other than C:/. Meanwhile as mentioned by #fjoe, stick with LTS versions especially v6.x.x.
Here are a few things to consider when picking your node.js version.
Version labelled as LTS (Long Term Support) are the releases they stand behind.
You can see a full list of versions here notice the LTS column. It is also interesting to see the versions of V8 and npm that are packaged with each.
Node 9.* has no official LTS release.
Node 8.* officially entered LTS on 10-31-2017 (3 months ago).
I personally have run into problems with it.
Node 7.* never officially released as LTS.
Node 6.* has 2 years of official LTS releases and they are continuing to support it.
With the most recent release on 01-02-2018.
Given this information might I recommend you try the proven long supported version 6.*
If this works then maybe hold off on version 8.* until more things get ironed out.
Other people have commented on your question about environment variables for node or npm. This is obviously not the issue as the commands are recognized and running (but they error).
Also I would recommend you follow this full uninstall guide: How to completely remove node.js from Windows
My coding buddy had a similar error yesterday, although on Linux.
The error was in the node_modules folder, so removing that and reinstalling node solved it for him.
That would be your node_module folder in AppData\Roaming\npm.
I guess the problem can be in NPM itself.
try to update your NPM.
Try to use this great approach
By the way, it's great to know what npm version you have with your changes of node.js versions.
From the logs you provided it looks like a cache bug, because of some junk that previously exists and that is causing issues.
Open the command prompt with admin privileges and follow the below steps:
1) Clear the cache: npm cache clean --force. You can also run npm cache verify.
2) Delete node_modules folder using: rm -rf node_modules.
3) Delete any package-lock.json file.
4) Remove the .npm directory.
5) Remove following directories :
5.1) C:\Users\<username>\AppData\Roaming\npm\.
5.2) C:\Users\<username>\AppData\Roaming\npm-cache.
6) Also, Try by setting environment variables:
C:\Users\<username>\AppData\Roaming\npm;C:\Program Files\nodejs.
Type in the command line: which npm.
Maybe you did not set the system value : NODE_PATH it should point to your global module location.
7) Update to the latest npm with npm i -g npm#latest.
Hope the above trick resolve your issue.
Thanks.
I guess while installing Node.js it don't able to set it's environment path due to permission.
You Need to configure Node path manually into environment variables.

EPERM: operation not permitted, lstat when running ng build

I'm getting an ERROR when trying to run ng build on my angular 4 app.
EPERM: operation not permitted, lstat '<dist directory>'
Has anyone encountered this issue?
TIA
I had the same problem.
As #Mauricio De La Quintana said, the problem is permission.
In my case (Windows environment), I solved the problem by removing the read-only property from the Repos folder and adding write permission to the Everyone user.
This probably a permission issue, just restart your IDE with admin permissions!
In my case I had to restart VsCode as administrator.
While running npm run build - I received error
Open Task Manager -> Select Chrome - > End Task
-> Select VSCode -> End Task
Opened the Project again -> Run npm run Build ---> worked for me
This has happened in my ASP.NET projects. For me this has happened for one of two reasons.
This can be a permission problem so you need to run Command Prompt as Admin.
a. Press win to open the start menu. Type in cmd to search for Command Prompt.
b. Press ctrl + shift + enter to launch Command Prompt as administrator.
This can happen when you build your web project in Visual Studio(or another IDE) and it is currently running.
a. This is a simple fix click the stop debugging and then try 'ng build' again.
Just restarted the VSCode and ran in admin. That solves my problem.
I saw this problem when running IISNODE...
Solution: Ensure that AppPool Identify from IIS has read permissions all the way from root of harddrive to website files.
Full answer is here https://github.com/tjanczuk/iisnode/issues/247
I had this issue while running a build on windows at the same time WSL was running in the directory. The issue was resolved by closing the WSL terminal.
Simply follow these steps
Restart VS Code
run npm run build
I think it is a permission problem, when you do ng build you also delete the previous files. I suggest using
sudo chown -R youruser /pathAngularApp
I had the same problem, and it was related to what #goku_da_master commented, I had the vueJs application running even when my VsCode stopped, I figured it out from the task manager and fixed it like this:
I opened the task manager
I searched if Node.js was running
Right click on the Node.js process
Finish Task
"npm run dev" again
I experienced the same problem. The fix for me was to install the correct node version that the project was requiring (an older one), then closing all terminal windows in VS Code, and relaunching VSC.
To switch node versions, I installed nvm and had to make sure the default alias was pointing towards the exact node version I wanted.
Error : Error: EPERM: operation not permitted, lstat 'C:\Users\Administrator'
We encountered this error after the Windows update.
This Solution worked for me;
Go to C:\Users\Administrator
Rename the file NTUSER.DAT as NTUSER-old.DAT

Categories