简体   繁体   中英

unable to create react new project

i was trying to create a new react project after installed the necessary packs "node.js" i ran code for creating the app as guided in the tutorial but the app does not created.this is the error message having receiving.

$ npm install -g create-react-app
C:\Users\LADE\AppData\Roaming\npm\create-react-app -> C:\Users\LADE\AppData\Roaming\npm\node_modules\create-react-app\index.js
+ create-react-app@3.3.1
added 41 packages from 32 contributors, removed 9 packages and updated 15 packages in 52.883s

LADE@DESKTOP-O0URVQ6 MINGW64 /c/wamp64/www
$ cd react-app/
bash: cd: react-app/: No such file or directory

LADE@DESKTOP-O0URVQ6 MINGW64 /c/wamp64/www
$ npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\wamp64\www\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\wamp64\www\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\LADE\AppData\Roaming\npm-cache\_logs\2020-02-01T03_01_13_432Z-debug.log

please help me with this. i don't understand as i am new to this.

You have not created a react application. Your first command installed the create-react-app globally.

$ npm install -g create-react-app

You then try to cd (Change Directory) into a directory react-app which does not exist with the command

$ cd react-app

What you want to do is simply run this command before the other commands

$ npx create-react-app react-app

Then you can issue the following commands

$ cd react-app
$ npm run start

Run the create-react-app command with the name of the application that you want to build, eg:

 $ npx create-react-app name-of-your-app

Note that you use 'npx' so that create-react-app doesn't have to be installed locally. After running that command a new directory with the same name as your app is automatically created with all of the files in it.

Also it's a good idea to test that you installed Node correctly. To test this just check the version using the following command line prompts. If it prints the version then you know you installed it correctly:

 $ node --version $ npm --version

You have successfully installed create-react-app , which is a popular toolchain for creating react based application.

npm start command is used to start your standard react app. But in this case, you haven't created a react app yet. That's why it's giving you an error.

So to create a react app, you have already installed create-react-app toolchain. The first step is done.

Now type npx create-react-app my-first-app in your terminal. It will take some time to create your react app.

Take note that you can call your react app anything you want (in this case its my-first-app ), but make sure that all characters of your react app name are lowercase.

Once its done creating your app, it will give you a success message. After that, you need to run cd my-first-app in your terminal.

Then you can run npm start to start your application.

Run all the commands with Administrator access to your Terminal/Command Prompt. I was getting the same errors until I ran all the code with Admin access.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM