Npm开始错误。应对

时间:2018-04-11 17:56:06

标签: reactjs npm

我正在尝试

  

npm start

在我的反应项目中,但总是有问题

npm ERR! path /Users/dan/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/dan/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and 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!     /Users/dan/.npm/_logs/2018-04-11T17_50_33_041Z-debug.log

我也知道5个版本的npm并不是最好的。因为我已经重新安装了npm,现在我已经

  

node -v

v8.11.1

  

npm -v

4.6.1

  

的package.json

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.3.1",
    "react-dom": "^16.3.1",
    "react-scripts": "1.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

3 个答案:

答案 0 :(得分:0)

尝试降级react-script

npm install react-scripts@2.1.8 --save

这对我有用!

答案 1 :(得分:0)

执行以下命令:

npx create-react-app myfirstreact
cd myfirstreact
npm start

答案 2 :(得分:0)

除非项目中没有文件可用,否则它应该可以工作。

检查您的反应样板模板是否完全由create-react-app生成,否则您需要升级您的create-react-app

了解未生成模板的一种方法是,项目目录中的src文件夹是否不存在。