PM2 Stopping without Starting - node.js

I am trying to install Dspace 7.0 on my Windows Server 2012. I have successfully installed the Backend according to the documentation
Now when I am installing the front end, I have installed Nodejs, Yarn, and PM2. also, yarn run build:prod seems to be successful.
After I created the below file, dspace-angular.json
{
"apps": [
{
"name": "dspace-angular",
"cwd": "/home/dspace/dspace-angular",
"script": "yarn",
"args": "run serve:ssr",
"interpreter": "none"
}
]
}
I need to run the below, according to the documentation.
But,
When I run pm2 start dspace-angular.json i get the below screen.
Right now I have no idea what to do next. Your kind help is highly appreciated.

Related

How deploy Laravel Inertia app with Inertia SSR on server

I have Laravel application, i use vue3 and inertia with SSR fore client side. It is typical laravel/jetstream app based Inertia - fully follows the documentation. I need deploy this app to VPS/VDS server. In the Inertia documentation they write how to build a client application https://inertiajs.com/server-side-rendering#building-your-app. It is just run node public/js/ssr.js, how i may do this on VPS/VDS hosting with SSH ?
you can use pm2, to run your ssr server in background,
install pm2, npm install pm2 -g.
go to your laravel app directory.
make new file ecosystem.config.json to root folder of laravel project with this command
nano ecosystem.config.json.
copy this code for ecosystem file.
Note: this code for Inertia.js v1.0
{
"apps": [{
"name": "laravel",
"script": "artisan",
"args": ["inertia:start-ssr"],
"instances": "1",
"wait_ready": true,
"autorestart": false,
"max_restarts": 1,
"interpreter" : "php",
"watch": true,
"error_file": "log/err.log",
"out_file": "log/out.log",
"log_file": "log/combined.log",
"time": true
}]
}
Run pm2 with this command pm2 start ecosystem.config.json
you can see all processes status with this command pm2 list and check <div> tags on your source site.
Good luck!

Node.js live debugging in VSCode doesn't work

I have a small project (but issue also appears on the one created by npx create-react-app my-app). I use VsCode and developing inside container (https://code.visualstudio.com/docs/remote/containers) . Dockerfile is very minimal:
ARG VARIANT="16-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
devcontainer.json has, almost, just defaults:
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
"args": { "VARIANT": "16-bullseye" }
},
"settings": {},
"extensions": [
"dbaeumer.vscode-eslint"
],
"remoteUser": "node"
}
To debug, I run npm start , then I (for the 1st time) i click on Debug URl.
On macOS everything works, including file monitoring, so when I change js file, npm is recompiling instantly.
On Windows 11 however, the last part doesn't work - I need to stop and start npm manually, to have changes implement.
I've even tried to remove .vscode directory from my profile - no change here...
Any idea what is going on? Why it does work on macOS and doesn't work on Windows ?
I have the same extensions on both systems...I just can't find what is going on with Windows machine...
EDIT: the issue seems to be related to "Remote Development" extension for vscode . Issue is present only when using this extension on Windows. So I've opened a bug there: https://github.com/microsoft/vscode-remote-release/issues/6633

Unable to configure MongoDB in Angular application that is using Express and Azure Cosmos DB

I am facing strange issue in configuring and using Azure CosmosDB MongoDB Api in angular application, the configuration and code is referred from https://learn.microsoft.com/en-us/azure/cosmos-db/tutorial-develop-mongodb-nodejs-part2 and https://johnpapa.net/angular-cosmosdb-1/, though i was able to configure and run application with express when i am trying to configure and install Mongoose node module getting series of errors :
1) Cannot find module 'mongodb-extjson 2) Cannot find module 'bson-ext' 3) ENOENT: no such file or directory, access 'XXX\node_modules\bson-ext\lib\package.json
I have tried re installing packages but no success.
I am using Angular version 10 with mongoose version 5.11.14
i am getting error at compile time when trying to run it from vs code and trying to launch server/index.js on port 3000.
Your help is greatly appriciated.
You are getting 1 and 2 because the MongoDB driver checks for optional requirements during initialization. You can F5 past them in VS Code. Or install them like so:
node install mongodb-extjson
node install bson-ext
Number 3 is also due to an exception during startup. I have no clue to why this is missing but if you want to skip initial throws in the debugger you can start without debugging first and then "attach" to it. Like so:
node --inspect --nolazy server/index.js
To attach to node with VSCode, make sure you have something like this in your .vscode\launch.json:
{
"name": "Docker: Attach to Node",
"type": "node",
"request": "attach",
"port": 9229,
"address": "localhost",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/",
"protocol": "inspector"
}
Many node modules test things at startup by throwing and catching. For example:
var hasStacks = false;
try {
throw new Error();
} catch (e) {
hasStacks = !!e.stack;
}
...and this leads to break in VS Code debugger. So you might want to attach (i.e. press run "Docker: Attach to Node" after a few seconds.

AWS Toolkit + VSCode local testing

I'm trying to figure out how to use AWS toolkit for vscode. I go to the AWS extension and click Create New SAM Application, point to project directory and it creates a hello world function. Above it, it says Add Debug Configuration. I click that, choose nodejs 12.x and save the launch.json, but I don't get the run option. It still says Add Debug Configuration for some reason. How can I run my lambda functions locally in the console?
The launch.json file generates, but I can never run the code.
launch.json
{
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "new test:app.lambdaHandler (nodejs12.x)",
"invokeTarget": {
"target": "code",
"projectRoot": "new test/hello-world",
"lambdaHandler": "app.lambdaHandler"
},
"lambda": {
"runtime": "nodejs12.x",
"payload": {},
"environmentVariables": {}
}
}
]
}
I also tried navigating to the hello-world directory in terminal and executing node app.js, but it doesn't return anything
What am I doing wrong? I appreciate the help!
Make sure you have SAM CLI install in local, here are the instructions for installation https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html
Then run the command sam local start-api.
You should be able to access the api at http://127.0.0.1:3000/hello
You can also do the same via vscode by selecting Run > Run without debugging (shortcut: ctrl + F5)

Azure Functions local HTTP trigger issue and solution

Just wanted to post the steps I took after running into the following error when trying to run an Azure Function HTTP Trigger locally in VS Code:
"[error] Incompatible Node.js version. The version you are using is v13.1.0,
but the runtime requires an LTS-covered major version. LTS-covered versions
have an even major version number (8.x, 10.x, etc.) as per
https://github.com/nodejs/Release#release-plan. For deployed code, change
WEBSITENODEDEFAULT_VERSION to '~10' in App Settings. Locally, install or
switch to a supported node version (make sure to quit and restart your code
editor to pick up the changes)."
(1.) install NVM. Instructions here: https://github.com/nvm-sh/nvm#installing-and-updating
(2.) install NVS. Instructions here: https://github.com/jasongin/nvs
(3.) in your VS code terminal, run:
nvs add 12.16.1
nvs use node/12.16.1/x64
(4.) edit your launch.json to the following:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Node Functions",
"type": "node",
"request": "attach",
"port": 5555,
"preLaunchTask": "func: host start"
}
],
"node": {
"runtimeVersion": "12.16.1"
}
}
(5.) in your VS code terminal, run:
func start

Resources