安装MongoDB后反应NPM启动错误

时间:2019-07-09 19:16:02

标签: reactjs mongodb express npm

我一直在做一个简单的项目,以帮助自己熟悉反应。我决定安装mongoDB以用于我的项目,但是安装后,我无法再启动我的应用程序。我根本没有为我的应用程序添加任何代码来与mongoDB进行通信,因此对于为什么这是一个问题我一无所知。

$ npm start

>client@0.1.0 start D:\Coding\react-router\client
>react-scripts start

npm ERR! file C:\Program Files\MongoDB\Server\4.0\bin
npm ERR! path C:\Program Files\MongoDB\Server\4.0\bin
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn C:\Program Files\MongoDB\Server\4.0\bin
npm ERR! client@0.1.0 start: `react-scripts start`
npm ERR! spawn C:\Program Files\MongoDB\Server\4.0\bin ENOENT
npm ERR!
npm ERR! Failed at the client@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\tonycheese\AppData\Roaming\npm-cache\_logs\2019-07-09T18_43_58_221Z-debug.log

这是在最后一行指定的完整日志

0 info it worked if it ends with ok
1 verbose cli [ 'D:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@6.4.1
3 info using node@v10.15.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle client@0.1.0~prestart: client@0.1.0
6 info lifecycle client@0.1.0~start: client@0.1.0
7 verbose lifecycle client@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle client@0.1.0~start: PATH: D:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Coding\react-router\client\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\ejohn\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;D:\Program Files\nodejs;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\Program Files\PuTTY;C:\Program Files\Git\cmd;C:\Users\ejohn\AppData\Local\Microsoft\WindowsApps;D:\Users\ejohn\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\ejohn\AppData\Roaming\npm;D:\Program Files\heroku\bin
9 verbose lifecycle client@0.1.0~start: CWD: D:\Coding\react-router\client
10 silly lifecycle client@0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 info lifecycle client@0.1.0~start: Failed to exec start script
12 silly lifecycle client@0.1.0~start: Returned: code: -4058  signal: null
13 info lifecycle client@0.1.0~start: Failed to exec start script
14 verbose stack Error: client@0.1.0 start: `react-scripts start`
14 verbose stack spawn C:\Program Files\MongoDB\Server\4.0\bin ENOENT
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
14 verbose stack     at onErrorNT (internal/child_process.js:415:16)
14 verbose stack     at process._tickCallback (internal/process/next_tick.js:63:19)
15 verbose pkgid client@0.1.0
16 verbose cwd D:\Coding\react-router\client
17 verbose Windows_NT 10.0.17763
18 verbose argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
19 verbose node v10.15.3
20 verbose npm  v6.4.1
21 error file C:\Program Files\MongoDB\Server\4.0\bin
22 error path C:\Program Files\MongoDB\Server\4.0\bin
23 error code ELIFECYCLE
24 error errno ENOENT
25 error syscall spawn C:\Program Files\MongoDB\Server\4.0\bin
26 error client@0.1.0 start: `react-scripts start`
26 error spawn C:\Program Files\MongoDB\Server\4.0\bin ENOENT
27 error Failed at the client@0.1.0 start script.
27 error This is probably not a problem with npm. There is likely additional logging output above.
28 verbose exit [ 1, true ]

这是我的package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "proxy": "http://localhost:5000/",
  "dependencies": {
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-router-dom": "^5.0.1",
    "react-scripts": "3.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

我的MongoDB配置文件

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: C:\Program Files\MongoDB\Server\4.0\data
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path:  C:\Program Files\MongoDB\Server\4.0\log\mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1


#processManagement:

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

1 个答案:

答案 0 :(得分:1)

节点正在尝试从C:\Program Files\MongoDB\Server\4.0\bin这个位置获取MongoDB文件。.检查位置并更新您的配置文件