Best practice for npm init - npm

Before creating any npm projects is it best practice to use npm init first? Like for example in react docus they did not specify to run npm init they just put npx create-react-app
Before creating any npm projects is it best practice to use npm init first? Like for example in react docus they did not specify to run npm init they just put npx create-react-app

Related

npx react-native init , not creating project

when I run new project command it shows me an error
npx react-native init AwesomProject
npm ERR! Could not install from "computer\AppData\Roaming\npm-cache_npx\15660" as it does not contain a package.json file.
try this : npm uninstall -g react-native-cli #react-native-community/cli
or
use Expo

What does "npm rebuild" actually do?

I've been struggling with a module that does not build after running npm rebuild (namely, #getinsomnia/node-libcurl), even though it does on npm install without --ignore-scripts.
I workaround that by running npx node-pre-gyp install in the module directory, but I'd like to understand why doesn't this behave as I expect it to do - build the module.
npm docs for npm rebuild say:
This command runs the npm build command on the matched folders.
What does npm build do though? Documentation for it only exists for npm v6 and not any newer releases, I can't run npm build on my npm v8 either ("unknown command"), and even that documentation doesn't say anything to me:
This is the plumbing command called by npm link and npm install.
It should generally be called during installation, but if you need to run it directly, run:
npm build

Where and How should I add AsyncStorage with React Native 0.59?

I just upgraded to react-native 0.59.0-rc.3 and I'm getting a warning about AsyncStorage that will be removed from react-native and added to #react-native-community/async-storage.
But in the #react-native-community/async-storage it only says how to link it, but not how to install it
e.g npm install some_package
Where Should I install it from?
npm install react-native-community and just import it from that?
npm install #react-native-community/async-storage?
As it states on the repo
# Install
$ yarn add #react-native-community/async-storage
Usually if a dependency is available with yarn it is available with npm
However, if you are using npm instead of yarn you can install it with
npm i #react-native-community/async-storage
yarn and npm are both package managers. Choose one and stick with it.
To see if a package is available for npm you can search on https://www.npmjs.com
As you can see from the below link that it is on npm and can be installed using npm i.
https://www.npmjs.com/package/#react-native-community/async-storage
The NPM package is #react-native-community/async-storage.
Have a look at the NPM page for it

How to avoid downloading all npm packages

While experimenting with React, I've come across the create-react-app GitHub project. As instructed, I did:
npm install -g create-react-app
create-react-app my-app
cd my-app
The issue here is 'node_modules' folder is full of npm packages rather than having only dependencies.
I'd like to know why this is happening and how can I fix this in order to download only dependencies.

React native not working in npm 5.3.0

I am new to React Native. I installed it by:
npm install -g create-react-native-app
When I tried
create-react-native-app MyProject
it shows that npm 5 is not supported yet and I need to downgrade npm.
If I will downgrade npm, will it affect other projects?
Is there any other way without downgrade npm?
You can downgrade your version of npm with npm install -g npm#4
Then, you can run create-react-native-app MyProject
You can download and use yarn instead of npm. If you change your npm version you have to use it with the other projects too. There are tools out there t let you use different versions of npm I think but I can't suggest anything because I never used them before.
I suggest you to use yarn.