why i am not able to install all the dependencies in react? - node.js

enter image description hereI tried running all the commands including npx create-react-app npm create-react-app npm install npm clear cache --f everything.
still i am not able to install all the dependencies in my package json

The fact that a package is asking for funding should not affect your installation. It simply means that the author(s) is/are looking for financial support to continue their work.
To create a new installation and avoid possible issues - go to a new directory and type the following on your command prompt:-
npx create-react-app todo1
Then, you need to navigate to the folder of your newly created app, "todo1" by running the following:
cd todo1
Finally to run the app, type the following:
npm start

First I want to say your commands are not clear and those are not separated. I assume you need to create react app with npm package manager.
If you run npx create-react-app todo1 you will create a react app with yarn dependency manager.
If you need to use npm dependency manager use the following command
npx create-react-app todo1 --use-npm
Then check the root directory. it should have the package.json file with necessary initial dependencies.

Related

Facing error while installing npm in react

I want to make a react project but when I execute npx create-react-app, it doesn't respond. Can anyone tell me what the issue I am facing here is? Screenshot.
make an empty folder then drag it over VSC, and type in terminal: npx create-react-app . (dot means in the current folder) also make sure u have node installed, type: node -v (to check what version u have)
From the official ReactJS Docs:
You’ll need to have Node >= 14.0.0 and npm >= 5.6 on your machine. To create a project, run:
npx create-react-app my-app
cd my-app
npm start
In the screenshot you provided, you indeed ran the command; but, it doesn’t show that you checked that the directory, visual, was created within your working directory, New folder. In addition, no error message was output; so as it stands, we know the npx command exists; and can only assume that, the command executed without error.
When using create-react-app:
A new directory will be created in the working directory (in your case, New folder) you run the command within.
This new directory will have the name of the argument you provided to create-react-app (in your case, visual).
So your directory structure you look like this:
New folder/
└─ visual/
The issue I see is that, the general output normally seen when running create-react-app (as shown here) did not appear in your screenshot; however, I’ve never ran it from MS PowerShell, as you appear to be. So you’ll want to check:
That you’re not overthinking this, and ensure that the, my-app, folder really wasn’t created;
And that your NodeJS version is either 14.0.0 or higher:
node -v
And that create-react-app was not installed globally:
To check this, run:
npm list -g
If you see create-react-app in the list, run:
npm uninstall -g create-react-app
npm install create-react-app
Or that running it from cmd (or cygwin) instead of powershell is maybe the better option.

npm and other modules commands not working

Note: I am on Windows 10 64 bit running the latest LTS Node build.
It all started when I tried running the command npm i -g create-react-app and I get a message saying that npm is not a command.
I checked my PATH and I believe I have the proper directories in there.
I navigated to the directory of npm and tried running the command again, but it still didn't work. I found that the command npm.cmd worked in any directory. So tried running npm.cmd i -g create-react-app and that worked! I also had to use the the command create-react-app.cmd my-app, instead of create-react-app my-app. I thought I was set and I could just use those .cmd commands for the things I needed to do; however, when I tried to run the command create-react-app.cmd my-app and got this as a result:
I have looked in the file that is ran when using this command create-react-app.cmd my-app and there is no sign of npm being called. Turns out Node is being called in that file with the command below. I know this because when I run it by itself and I get the same output to the console seen in the previous image.
"node" "C:\Users\Allen\AppData\Roaming\npm\\node_modules\create-react-app\index.js" my-app
it was called in the create-react-app.cmd file like this "%_prog%" "%dp0%\node_modules\create-react-app\index.js" %*
I am at a loss. I could continue down this rabbit hole and try and find the node file that is calling npm and change it to npm.cmd but I would rather find a way to get the npm and create-react-app commands working as they are suppose to. At the very least I can just spin up a VM and work in that. It is just annoying that I can't get Node to work properly for me.
Use the command npx create-react-app my-app this will help you create react projects.
Also check the documentation : https://reactjs.org/
First check that you have npm installed on your machine and the version. You can just type npm version. Since npm version 5.2.0 npx is pre-bundled with npm, which is a CLI tool whose purpose is to make it easy to install and manage dependencies hosted in the npm registry. So try using npx create-react-app app-name. You can confirm that you are able to use npx by running which npx. If it is not available then you can install it by running npm install -g npx.

NodeJS - npm install practice

Created new folder and did npm install serve in it.
It created package-lock.json and node_modules/ folder.
When I run in the same folder serve it shows error:
command not found: serve
What is the way to install?
I am using: npm#6.5.0
My dev environment is MACOS
I read a great many pages on this topic and nothing worked until I tried the following
./node_modules/.bin/serve -s build
Also if you are using VS CODE you may want to bring up the terminal window outside of VS CODE - this seems to have snared a lot of people.
First of all, you should start your project running
npm init
This will create the package.json file.
Then, you can install the serve package globally.
npm install -g serve
And now you can run serve.
The serve binary was not found because the operating system cannot locate it in the PATH environment variable.
When you do the npm install serve command. The serve module is only installed into the node_modules directory found under the the project folder. Unless you explicitly include the absolute path of this node_module directory as part of your PATH env var, the OS won't know where to find serve.
Like others say, the typical practise would be to install the module using the -g flag. G means global.
When -g is used, npm will put the binary in its node directory somewhere and this this directory would have been included as part of your PATH when you install node, thus making the any new binary discoverable.
If the node.js module has a "command" and you want to run it without installing the module globally(npm install -g serve). You can run it like ./node-modules/.bin/command from the root folder of the project.
Now, what is generally used is npx, so that you can from within a project easily run any of the binaries within its local node_modules or your system's global node_modules/ and any other commands on the $PATH.
For example, here we install webpack as a local dependency. You can image doing this in a folder after running npm init. Then we run webpack without having to worry about referencing the bin file:
$ npm i -D webpack
$ npx webpack

Node js - how to publish a package and let user run a single command to start the server

I have made a npm package for the first time. For my daily dev, I have used npm start to start the server and then user can use localhost:3000 to view the pages.
When I try to publish that to end users, I can still ask people to use npm install > npm start to use the package. However, it doesn't sound decent.
How can I make people being able to use:
npm install myPackage
myPackage start
to start the server and then they can open localhost: 3000 directly?
You can make a global module and attach it to a bin command.
Here's the tutorial for that by npm itself.
In your package.json file, you can add this:
"bin": {
"your-command": "bin/path/to/js/file.js"
}
and then whenever the user installs your module globally, then they can directly type in that command and the js file will execute your code.
You need to create global package for your module so that it can be installed
npm i -g module
then provide some config file like gulpfile.js which will be used by your package to carry out the task to start server any other task

Making "sudo npm install --save-dev gulp" in Maverics nothing's happens

I'm trying to test Gulp and I find this problem.
I installed Gulp globally with: sudo npm install -g gulp.
Then I was created the folder: mkdir my-gulp
cd my-gulp
And the I try to do this: sudo npm install --save-dev gulp
It seems work fine, no errors, but my folder my-gulp continues empty.
I can see in console, this line:
gulp#3.8.6 ../../node_modules/gulp
And I thinkig the problem is here "../../", I think it must be "gulp#3.8.6 node_modules/gulp"
What do you think? Maybe is something about $PATH?
First, you should never run npm via sudo for local packages. (In fact, you shouldn't run it as root ever, but that's a different, more complex issue to solve.)
Second, you need to initialize NPM before you can install packages. It sounds like you didn't do this.
There's two ways:
If you have an existing package.json, which contains the required information about a project, you can copy it into your folder, then edit in a text editor of your choice to get started. If the package.json includes existing dependencies, you can either remove them, or run npm i in the folder to install them.
If you are starting fresh, run npm init to set up a new package.
Once you have a valid package.json, you can install packages into your application.
As to why you are seeing ../../gulp, I'm guessing you have a package.json further up the file tree somewhere.

Resources