使用 npm 脚本启动 mongodb 服务器
我正在使用 cmd 和以下命令启动 mongodb 服务器:
I am starting mongodb server using cmd with the following command:
"C:/Program Files/MongoDB/Server/3.6/bin/mongod.exe"
"C:/Program Files/MongoDB/Server/3.6/bin/mongod.exe"
完美启动mongodb服务器.
It starts the mongodb server perfectly.
现在我需要通过 npm 脚本来完成.下面是我的 package.json 文件:
Now I need to do it via npm script. Below is my package.json file:
package.json:
"scripts": {
"ng": "ng",
"prestart": "start /b \"C:/Program Files/MongoDB/Server/3.6/bin/mongod.exe\"",
"start": "ng serve | node server.js",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
现在当我点击 npm start 时,它不会启动 mongodb 服务器.
Now when I hit npm start, it doesn't starts the mongodb server.
我还在环境变量(用户和系统)中包含了路径C:/Program Files/MongoDB/Server/3.6/bin/mongod.exe".
I also included the path "C:/Program Files/MongoDB/Server/3.6/bin/mongod.exe" in environment variables (both user&system).
谁能帮我知道我错在哪里?
Can anyone help me to know where I was wrong?
我阅读了 start cmd 命令的帮助,并且能够在单独的命名窗口中运行它:
I read help for the start cmd command and was able to run it in a separate named window:
"scripts": {
"db": "start \"ToDo MongoDB instance\" /D \"C:/Program Files/MongoDB/Server/4.0/bin/\" mongod.exe --dbpath=\"C:/GIT/NodeJS/todo/db\""
},