What do I do now that watchman is deprecated? - node.js

https://www.npmjs.com/package/watchman
This was the only fix to npm start not working for react native. Is there a way to force this to install even though its deprecated?

I figured out that I should be using the react native cli package and not the create react native app package. If you are experiencing issue with react native I recommend you use the command below to install react native to your package.json
npm install react-native-cli --save
Use the command below to make your react native app.
react-native init appName
And from there it will build the app and as long as you have Android Studio set up properly you can can easily call
react-native run-android
to start your app in the emulator.

Related

Is it necessary to install Electron module and save it as devDependencies in project folder or install it globally?

I'm working with Electron to build an app and I find that we can install Electron module globally by npm install -g electron instead of npm install --save-dev electron as the documentations said. I think this will reduce the app size. But I'm afraid of there will be an error when packaging the source code or while the user use the app. Can we install Electron module globally without any error and if can, will the app size reduce when we package it?
Installing Electron locally (within your project) or globally will make no difference to the size of the built application.
It is common practice to install Electron locally within your project as a dev-dependency. Doing so will prevent the need to constantly change its version number when working on different Electron applications should their Electron version numbers differ.
When your application is built, all the necessary binaries, etc are packaged up within your application. IE: Your built Electron application is self-contained.
No, you need to install it locally in the package, because as you say, packaging the app will fail.
Actually, you won't even be able to build your app.
Something like what you're describing has been suggested on their Github page. See here, but I doubt they'll implement this any time soon.

React version issue. Not able to upgrade version

I am not able to install latest version of react. Actually I installed a particlar version after appending # , after that what ever I am doing it is not working. even I unistalled nodejs completely. still it is not working.
npm react --version
6.14.15
Then I ran this
npm install --save react#latest
After that version is still coming same.
npm react --version
6.14.15
After that I uninstalled react using below
npm uninstall -g create-react-app
I also did
npm uninstall react
and then checked the version. it is still coming same.
I followed onw blog and tried below. still it dint work.
npm install react-scripts#4.0.0 react#17.0.0 react-dom#17.0.0
and installed react again. still it is giving same version.
Could you please help me on the same.
Is there any to remove it completely from the system?
Let understand the diff between react and create react app.
React is a js library for creating user interfaces but and create react app is a cli tool that help us to create the files template for a react project and both are totally different npm packages.
The create react app doesn't depend on react so it doesn't install the required version of react.
If you want to upgrade your react library you have to install react
npm i -g react#latest

starting react native app

I'm starting work on React Native, using create-reactive-native-app and Exponent. There is a nice list of open source examples here, some of then are mentioned to use Exponent.
https://github.com/ReactNativeNews/React-Native-Apps
I have few experience with nodejs. I already noticed there are several possible configurations for React Native apps. I usually use npm start to run it, but that don't work on those examples, since since they don't have a start script in package.json.
Take as an example the native-component-list app. How can I execute it after cloning and doing npm install?
Using node v6.11.4 and npm 3.10.10
I also tried using react-native run-android . It works when I create a new project with react-native init Ola2
But not with the downloaded code.
Here are some more details. I did this before: npm install -g react-native-cli
npm install
react-native run-android
Scanning folders for symlinks in xxx/native-component-list/node_modules (25ms)
Android project not found. Maybe run react-native android first?
react-native android
Scanning folders for symlinks in xxx/native-component-list/node_modules (26ms)
Unrecognized command 'android'
Run react-native --help to see list of all available commands
As per this link, you can run the app with command react-native run-android (for android)
I found the problem. I just had never used Expo.io way to create a ReactNative app. I only knew the init and the crna ways. This apps where created with the exp tool.
So,to run it, just do:
npm install exp --global
npm install
exp android
exp start
I didn't work on Expo, I prefer react-native-cli
In your case, your project in developed on Expo.
So you need expo-cli to run the project.
For Expo Cli
npm install -g expo-cli
For CRNA
npm i -g create-react-native-app
Internally CRNA use EXPO, so you can choose any option. After installing the expo-cli npm start command work fine for you.
Or you can eject this project.
You can run npm run eject to get a project very similar to what react-native init would generate. At that point you’ll need Xcode and/or Android Studio just as you would if you started with react-native init , adding libraries with react-native link will work, and you’ll have full control over the native code compilation process.
Hope it will work for you.

FAIL Inject RemoteDev monitor into React Native debugger

I am working on a React Native app and suddenly see this :
FAIL Inject RemoteDev monitor into React Native debugger, the file 'react-native\local-cli\server\util\debugger.html' not found.
when i run npm install.
It used to be ok before. I checked the folder AppData\Roaming\npm\node_modules\react-native\local-cli\server\util and the debugger.html file is there.
Here is my package.json script:
"postinstall": "remotedev-debugger"
How can I fix this?
I got this error today after updating to the latest React Native version.
I think you need to update RemoteDev package.
For me, this involved replacing remote-redux-devtools-on-debugger with the latest remotedev-rn-debugger (https://github.com/jhen0409/remotedev-rn-debugger) as the package name had changed.
Upgrade the remotedev-rn-debugger package.
If you use NPM:
npm i remotedev-rn-debugger#latest --save-dev
If you use Yarn:
yarn add remotedev-rn-debugger#latest --dev

Using NodeJS plugins in Electron

I am new to Electron (Atom-shell), and I am trying to load a NodeJS plugin into the application I am building, but I don't know how. The documentation is not clear on that.
For instance, I am trying to use sqlite3 plugin in my app, I used npm install sqlite3, and it was successfully installed. But the application throws and error when I try to call it var sqlite = require('sqlite3'). Are there any further steps I am not aware of ?
Thanks.
For pure JS (i.e. not native) modules you need the following:
Have the module listed in your package.json dependencies
Let electron know where to find the module (e.g. export NODE_PATH=/PATH/TO/node_module)
The first requirement is obvious and the second has its roots in this issue.
For native node modules (such as sqlite3) which use C++ bindings, you need to build them against electron headers to work. According to electron docs, the easiest way to do that would be:
npm install --save-dev electron-rebuild
# Every time you run npm install, run this
./node_modules/.bin/electron-rebuild
To install the npm modules correctly you should go into the folder of your electron app and install the module via npm.
npm install --save sqlite3
The flag --save is important, because npm will install the module inside your app.
Afterwards the require should work.

Resources