can not setup ReactJS on mac

2019-09-15 00:55发布

问题:

I need to setup ReactJS on my Mac. I have npm version of 4.1.2 and node version of v7.7.4. I clone the project from Git and in the project folder trying to execute npm install and following npm start. But I get error. I removed&uninstalled node and npm and then re-installed with homebrew, but it did not help. Here is the screen of error I get in terminal? Do you have any idea what is the problem?

Here is my package.json file

{
  "name": "viaopt",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {},
  "devDependencies": {
    "webpack": "^2.3.0"
  },
  "description": ""
}

回答1:

From the error you are showing I can tell that there is no start script in your package.json file. For npm start to work there should be a command under the start key under the scripts attribute in your package.json file.

When you run npm start npm looks in package.json and runs whatever is listed there under the start value.

I'm guessing you have gulp or webpack configured with your project?

Try running webpack in your terminal and see if your project fires up or smth.

Hopes this helps. Cheers.



回答2:

If your trying to setup a new React App you can use Create React App. It will setup React / Webpack for you.