0

In order to initialize the local mongoDB server, I have to run the following command from the root directory in the terminal :

/'Program Files'/MongoDB/Server/4.4/bin/mongod.exe --dbpath=/MongoDB_Data

Now, I wish to insert a script in package.json:

"start_server" = "/'Program Files'/MongoDB/Server/4.4/bin/mongod.exe --dbpath=/MongoDB_Data"

so that I only need to run npm run create_server to execute the command. But it throws this error:

'/'Program' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] create_server: `/'Program Files'/MongoDB/Server/4.4/bin/mongod.exe --dbpath=/MongoDB_Data`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] create_server 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\ASUS\AppData\Roaming\npm-cache\_logs\2021-01-31T13_36_01_276Z-debug.log

Can someone please tell me how to fix this? I'm still a beginner.

1

1 Answer 1

0

Have you tried to escape the white space with a backslash?

"start_server" = "/'Program\ Files'/MongoDB/Server/4.4/bin/mongod.exe --dbpath=/MongoDB_Data"

I'm not sure it will solve it, it's a long time since I used Windows

Sign up to request clarification or add additional context in comments.

1 Comment

it throws an error in the editor (VS Code) itself, saying :- "Invalid escape character in string."

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.