Js doee
Js doee

Reputation: 333

how to use forever with npm

i am trying to run this command in my debian 10 vps forever start npm start but i got this error in the terminal,

warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info:    Forever processing file: npm
(node:23858) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:23858) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
error:   Cannot start forever
error:   script /root/node_projects/tiktok/backend/npm does not exist.

Here is my package.json file

{
  "name": "auth-graphql",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.js",
  "engines": {
    "node": "10.11.0"
  },  
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "node -r esm ./src/index.js",
    "start": "nodemon -r esm ./src/index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    ...
    "esm": "^3.2.0",
    ...
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-2": "^6.24.1",
    "nodemon": "^1.18.4"
  }
}

i tried

forever start  esm ./src/index.js

forever start -c "npm start" ./

forever start -c "npm start" /path/dir/

forever --sourceDir /path/dir/ -c "npm start" /

and i also got almost the same error, Please I need help, How can i solve this problem

Upvotes: 5

Views: 5160

Answers (3)

Vinodh Ram
Vinodh Ram

Reputation: 809

I don't know the solution but. The problem is related to a circular dependency. Node version 14+ is no longer supports circular dependency. Example In fileA

var fileB = require(fileB);

In fileB

var fileA = require(fileA);

Upvotes: 0

Peter Nixey
Peter Nixey

Reputation: 16575

I've had similar problems and I think it may be some sort of incompatibility with NPM/Node versions (see discussion here.

I switched to https://github.com/Unitech/pm2 instead and things started working immediately.

Upvotes: 0

try this command:

forever start -c "npm start" ./

running your application's specific directory:

forever start -c "npm start" /path/dir/

or use this command:

forever --sourceDir /path/dir/ -c "npm start" /

Upvotes: 2

Related Questions