Npm 无法启动网页包开发服务器

Npm 无法启动网页包开发服务器,npm,webpack-dev-server,Npm,Webpack Dev Server,我正在尝试做React教程,虽然我已经从讲师那里下载了文件,但我无法在笔记本电脑上启动web开发服务器。不过,我可以让它在我的台式电脑上工作。不过,我需要能够在笔记本电脑上工作,所以如果有人能帮我找出问题所在,我将不胜感激。我尝试过删除并重新安装node_modules文件夹(多次),以及只删除webpack dev server文件夹并重新安装。据我所知,没有其他程序使用相同的端口(8080) 这是我得到的错误日志: 0 info it worked if it ends with ok 1

我正在尝试做React教程,虽然我已经从讲师那里下载了文件,但我无法在笔记本电脑上启动web开发服务器。不过,我可以让它在我的台式电脑上工作。不过,我需要能够在笔记本电脑上工作,所以如果有人能帮我找出问题所在,我将不胜感激。我尝试过删除并重新安装node_modules文件夹(多次),以及只删除webpack dev server文件夹并重新安装。据我所知,没有其他程序使用相同的端口(8080)

这是我得到的错误日志:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.4.0
3 info using node@v8.11.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle github-battle@1.0.0~prestart: github-battle@1.0.0
6 info lifecycle github-battle@1.0.0~start: github-battle@1.0.0
7 verbose lifecycle github-battle@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle github-battle@1.0.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/eleerogers/Downloads/react-fundamentals-first-component/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
9 verbose lifecycle github-battle@1.0.0~start: CWD: /Users/eleerogers/Downloads/react-fundamentals-first-component
10 silly lifecycle github-battle@1.0.0~start: Args: [ '-c', 'webpack-dev-server --open' ]
11 silly lifecycle github-battle@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle github-battle@1.0.0~start: Failed to exec start script
13 verbose stack Error: github-battle@1.0.0 start: `webpack-dev-server --open`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:304:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid github-battle@1.0.0
15 verbose cwd /Users/eleerogers/Downloads/react-fundamentals-first-component
16 verbose Darwin 17.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v8.11.3
19 verbose npm  v6.4.0
20 error code ELIFECYCLE
21 error errno 1
22 error github-battle@1.0.0 start: `webpack-dev-server --open`
22 error Exit status 1
23 error Failed at the github-battle@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
下面是package.json:

{
  "name": "github-battle",
  "version": "1.0.0",
  "description": "Project for TylerMcGinnis.com's fundamental course.",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --open"
  },
  "author": "Tyler McGinnis",
  "license": "MIT",
  "babel": {
    "presets": [
      "env",
      "react"
    ]
  },
  "dependencies": {
    "react": "^16.0.0-alpha.5",
    "react-dom": "^16.0.0-alpha.5"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-plugin-transform-async-to-generator": "^6.24.1",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "css-loader": "^0.28.11",
    "html-webpack-plugin": "^3.2.0",
    "style-loader": "^0.21.0",
    "webpack": "^4.8.3",
    "webpack-cli": "^2.1.4",
    "webpack-dev-server": "^3.1.5"
  }
}
虽然,正如我所说,它在我的桌面上工作,所以我不认为它有什么问题。。。我的笔记本电脑出了问题。这是一款新的MacBookAir。谢谢你的帮助

npm清理缓存

然后

npm安装

这将解决您的问题。

npm clean cache

然后

npm安装

这应该可以解决您的问题。

我尝试了这个(“npm缓存清理-强制”,然后是“npm安装”…还尝试了“sudo npm缓存清理-f”,然后是“sudo npm安装”npm@latest-g”),但我仍然收到相同的错误消息。谢谢你的建议!我试过这个(“npm缓存清理-强制”,后面是“npm安装”…还试过“sudo npm缓存清理-f”,后面是“sudo npm安装”npm@latest-g”),但我仍然收到相同的错误消息。谢谢你的建议!
{
  "name": "github-battle",
  "version": "1.0.0",
  "description": "Project for TylerMcGinnis.com's fundamental course.",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --open"
  },
  "author": "Tyler McGinnis",
  "license": "MIT",
  "babel": {
    "presets": [
      "env",
      "react"
    ]
  },
  "dependencies": {
    "react": "^16.0.0-alpha.5",
    "react-dom": "^16.0.0-alpha.5"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-plugin-transform-async-to-generator": "^6.24.1",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "css-loader": "^0.28.11",
    "html-webpack-plugin": "^3.2.0",
    "style-loader": "^0.21.0",
    "webpack": "^4.8.3",
    "webpack-cli": "^2.1.4",
    "webpack-dev-server": "^3.1.5"
  }
}