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
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" /
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.
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);
Related
I have a very basic Express server setup with NodeJS/Express + Nodemon. I'm using WebStorm as my IDE.
When running the debug/inspect script, my application is throwing a compile-time error. Following the instructions here, and cognizant of the post here, my (simplified) package.json looks like this:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon src/app.ts",
"debug": "nodemon --inspect=127.0.0.1:9229 src/app.ts"
},
"devDependencies": {
"#types/express": "^4.17.9",
"#types/node": "^14.14.19",
"nodemon": "^2.0.6",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
}
When I run npm run debug I receive the following error:
I've also tried the following, all with the same result:
"debug": "nodemon --inspect src/app.ts"
"debug": "nodemon --inspect=0.0.0.0:9229 src/app.ts"
Any ideas why this error is occurring?
The command npm run dev does not generate an error. Upon further investigation, nodemon automatically substitutes ts-node when targeting a .ts file. Ts-node, in turn, recommends debugging by registering ts-node and running the server with the node command.
If you need to use advanced node.js CLI arguments (e.g. --inspect),
use them with node -r ts-node/register instead of the ts-node CLI.
You can modify your script as follows:
"debug": "nodemon --exec \"node --inspect-brk=0.0.0.0:9229 --require ts-node/register src/app.ts\""
to make sure that the --inspect-brk is passed to Node.js and not to ts-node
I am using A2hosting and trying to configure cron worker, but no luck yet.
I followed this article to install node and npm, which is basically list of commands below
cd ~
wget https://nodejs.org/dist/v12.9.1/node-v12.9.1-linux-x64.tar.xz
tar xvf node-v12.9.1-linux-x64.tar.xz
mv node-v12.9.1-linux-x64 nodejs
mkdir ~/bin
cp nodejs/bin/node ~/bin
cd ~/bin
ln -s ../nodejs/lib/node_modules/npm/bin/npm-cli.js npm
I have tried multiple commands
npm run --prefix ~/cloudflare-upload-tool start which produces /bin/bash: npm: command not found
and
~/nodejs/bin/npm run --prefix ~/cloudflare-upload-tool start which produces /usr/bin/env: node: No such file or directory
Both commands run fine in terminal, could you tell what are my options to fix this?
package.json
{
"name": "cloudflare-upload-tool",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "env-cmd node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.20.0",
"cloudflare": "^2.7.0",
"env-cmd": "^10.1.0",
"form-data": "^3.0.0",
"fs": "0.0.1-security",
"jsonwebtoken": "^8.5.1",
"path": "^0.12.7",
"tus-js-client": "^2.2.0"
}
}
Support told that this approach is not supported. Ended up creating node js app using UI, stopping it as we don't need to expose it and using command for cron worker below as suggested in other article
source /home/<USERNAME>/nodevenv/cloudflare_upload_tool/10/bin/activate && cd /home/<USERNAME>/cloudflare_upload_tool && npm run start
(having node version 12 and npm version 6)
Backend: Node.js
Front: React.js
i cloned repository
cd into the directory
ran
npm install (installing dependencies etc...)
and when i ran
npm start
and i get
[Ben#Mac:~/Desktop/test]$ npm start
> answers-entry-level-exam#1.0.0 start /Users/Ben/Desktop/test
> lerna run start --parallel
lerna notice cli v3.22.1
lerna info Executing command in 1 package: "npm run start"
#ans-exam/server: > #ans-exam/server#1.0.0 start
/Users/Ben/Desktop/test/server
#ans-exam/server: > ts-node-dev index.ts
#ans-exam/server: Using ts-node version 8.5.2, typescript version 3.7.2
#ans-exam/server: server running 3232
which seems like the server is running okay
but localhost:3000 cant be reached
not opening anything
the first time it did open and there was a MacOS popup on the right side of the screen related to node ( i think that is the issue but cant figure out how to fix)
my package.json:
{
"name": "answers-entry-level-exam",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"b": "npm run bootstrap",
"bootstrap": "lerna bootstrap",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "lerna run start --parallel",
"postinstall": "npm run bootstrap"
},
"author": "",
"license": "ISC",
"devDependencies": {
"lerna": "^3.22.1"
}
}
Thanks!
I cloned again the repo and it fixed that
Cheers to all those who tried to help :)
Try localhost:3232. I see in your output server running 3232
I am new in node.js so unable to understand error properly. As per the sails document https://sailsjs.com/documentation/concepts/deployment
I am trying to execute a sails.js application with NODE_ENV=production node app.js but it is throwing some errors. While it is working fine with for development environment with npm run dev
For now disabled session in my project. Now other warnings has been removed.
$ NODE_ENV=production node app
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
Aborted due to warnings.
Running "babel:dist" (babel) task
Warning: .tmp/public/js/sdk.js: 'with' in strict mode (22:780)
------------------------------------------------------------------------
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to resume watching for changes to assets:
error: CTRL+C, then `sails lift`
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and any custom Grunt plugins you're using installed in this project?
error: Run `npm install` if you're not sure.
error:
error: *-> You might have a typo in one of your LESS files, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `C:\xampp\htdocs\soochna_sails\.tmp` ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R YOUR_COMPUTER_USER_NAME C:\xampp\htdocs\soochna_sails\.tmp
error:
error: *-> If you're still unsure, drop by https://sailsjs.com/support.
my package.json file is
"description": "a Sails application",
"keywords": [],
"dependencies": {
"#sailshq/connect-redis": "^3.2.1",
"#sailshq/lodash": "^3.10.3",
"#sailshq/socket.io-redis": "^5.2.0",
"async": "2.0.1",
"grunt": "1.0.1",
"nodemon": "^1.17.5",
"sails": "^1.0.2",
"sails-hook-autoreload-extend": "^1.0.4",
"sails-hook-grunt": "^3.0.2",
"sails-hook-orm": "^2.0.0-16",
"sails-hook-sockets": "^1.4.0",
"sails-mysql": "1.0.0",
"dropzone": "5.5.1"
},
"devDependencies": {
"#sailshq/eslint": "^4.19.3"
},
"scripts": {
"start": "NODE_ENV=production --ignore 'tmp/*' node app.js",
"dev": "set NODE_ENV=development && nodemon --ignore 'tmp/*' app.js && exit 0",
"test": "npm run lint && npm run custom-tests && echo 'Done.'",
"lint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'",
"custom-tests": "echo \"(No other custom tests yet.)\" && echo"
},
"main": "app.js",
"repository": {
"type": "git",
"url": "git://github.com/xxxxxxx/test-project.git"
},
"license": "",
"engines": {
"node": ">=9.11"
}
Any help will be appreciated.
I ran into this issue aswell, quite a lot. This is the interesting part:
error: *-> Or maybe you don't have permissions to access the .tmp directory?
error: e.g., C:\xampp\htdocs\soochna_sails\.tmp ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R YOUR_COMPUTER_USER_NAME C:\xampp\htdocs\soochna_sails.tmp
You are obviously hosting on windows, so try making the .tmp folder write accessible or delete it manually prior to launching your application in production mode.
I'm building a project which I have multiple instances of running, with the exact same code, using forever.
With forever, it's possible to set an id, using --id "id".
{
"name": "project",
"version": "1.0.0",
"description": "Test",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"forever": "forever start --id $1 -c \"npm start\" ./"
},
"author": "Renzo <renzo#geex.company>",
"license": "ISC"
}
This way, I'm trying to make a standard for different app instances like:
npm run forever cms
The idea is that this would start the app with id cms.
But instead, it lists the app with id true.
Can anyone help me?
Try changing this:
npm run forever cms
to this:
npm run forever -- cms
but you'd also have to change the order of arguments in package.json.
Also, you can put this in a script, like forever.sh:
#!/bin/sh
forever start --id $1 -c "npm start" ./
and this in package.json:
"scripts": {
"forever": "sh forever.sh"
},
and then use this from the command line:
npm run forever -- cms
To make it work on Windows see these answers:
Why does `DEBUG=foo node index.js` fails in `scripts` section of `package.json`
'bash' is not recognized as an internal or external command
NPM script under cygwin/windows: the syntax of the command is incorrect
This is more of a workaround than an answer, but for now I'm doing it like this:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"forever": "forever start --id $ncmsfid -c \"npm start\" ./",
},
And starting it with ncmsfid=cms npm run forever