John
John

Reputation: 195

run npm start in Js file

I'm trying to run 'npm start' from a file : test.js . I get :

(function (exports, require, module, __filename, __dirname) { npm start
                                                              ^^^^
SyntaxError: Unexpected identifier

The content of test.js :

npm start 

What I'm trying to achieve is to avoid starting my node server with npm start directly in the shell and start it with:

node test.js

And programmatically restart my node server at three differents hours a day.

I'm not node expert. Can anyone help me or give me ideas to achieve this ? Thank you.

Upvotes: 0

Views: 1165

Answers (1)

shawon191
shawon191

Reputation: 1955

npm start is not a valid javascript code rather it is a command meant to be used from the terminal. To do scheduled restarts you can use modules like pm2.

Upvotes: 1

Related Questions