Raspberry Pi experiences issues with PM2

I attempted to set up pm2 on a Raspberry Pi. I used the command sudo npm install -g pm2:

pi@raspberrypi:~ $ sudo npm install -g pm2
/usr/bin/pm2 -> /usr/lib/node_modules/pm2/bin/pm2
/usr/bin/pm2-dev -> /usr/lib/node_modules/pm2/bin/pm2-dev
/usr/bin/pm2-docker -> /usr/lib/node_modules/pm2/bin/pm2-docker
/usr/bin/pm2-runtime -> /usr/lib/node_modules/pm2/bin/pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a0c190f1c0f041e192a58445b445b">[email protected]</a> (node_modules/pm2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="81e7f2e4f7e4eff5f2c1b3afb0afb0">[email protected]</a>: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})

+ <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e6e732c5e2a302f302c">[email protected]</a>
updated 3 packages in 16.284s

However, whenever I try to run pm2, I encounter the following error:

pi@raspberrypi:~ $ pm2 start script.sh
/usr/lib/node_modules/pm2/node_modules/has-flag/index.js:1
24 �ubelet.goz0t4] node "rispberrypy-1# not found
   ^

SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/usr/lib/node_modules/pm2/node_modules/supports-color/index.js:3:17)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

In this scenario, I used pm2 start but ran into the same issue with any of the pm2 commands

Could you help me identify and resolve this error?

Thank you

Answer №1

When using pm2, remember to initiate a node.js script instead of trying to run script.sh. It's recommended to place the pm2 command inside the script itself and then proceed with executing the script :)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The dynamic trio: Node.js, Sequelize, and SQL Server working together

I'm currently working with SQL Server 2005 and node.js, utilizing the following dependencies: "dependencies": { "sequelize": "^4.42.0", "tedious": "^5.0.3" } My objective is to set up this database structure: const con = require('. ...

The signature does not match, so the SignedURL is being rejected

I recently started using AWS S3 and encountered the SignatureDoesNotMatch error while trying to upload an image. I double-checked for any typos in my keys, ensured that my system time was accurate, but still couldn't resolve the issue. My workflow, mo ...

Retrieving a single object from an array in node.js utilizing elemMatch

My goal is to extract a single object from an array of objects in a data collection using elemMatch. Here is the sample data: [ { "_id": "5ba10e24e1e9f4062801ddeb", "user": { "_id": "5b9b9097650c3414ac96bacc", "firstName": "blah", ...

What is the best way to retrieve a list of fields from a set of JSON documents?

Currently, I am facing a scenario where I have two MongoDB collections named stu_creds and stu_profile. My objective is to initially fetch all the student records from the stu_creds collection where the stu_pref_contact field corresponds to email. Subseque ...

Is there a permanent solution to fixing the error code -4094 that is repeatedly occurring during React Native startup?

When attempting to execute react-native start, an error occurred which has not been encountered before. The error message is as follows: ERROR ENCOUNTERED Loading dependency graph...events.js:287 throw er; // Unhandled 'error' event ...

NodeJS: Implement session refresh mechanism following permission changes made by other users

Utilizing express-session in my NodeJS application for managing sessions, express-mysql-session to store session data in MariaDB, Passport for authentication, and Sequelize for ORM. Encountering an issue where I am unsure how to refresh a user's sess ...

Ways to properly release file descriptors in write streams

I'm currently working on a code snippet that showcases what I'm aiming to achieve: const fs = require('fs'); var stream = fs.createWriteStream('/tmp/file'); stream.once('open', function(fd) { for (var i = 0; i ...

Retrieving data from various schemas using Node.js

I am managing two schemas, one for employees (parent) and the other for assessments (child). Each assessment is linked to an employee ID with a pass percentage. Here are some sample data: employees : [ { "_id": 12345, "name": "David", "eval ...

Set up webpack to select jquery.min.js over jquery.js located in the node_modules directory

Can webpack be instructed to use `jquery.min.js` instead of `jquery.js` from the `node_modules/jquery` directory when generating the `bundle.js` file? ...

What steps can be taken to confirm that the library or package I am responsible for maintaining remains compatible with previous versions?

As the caretaker of a library or package distributed through various package managers like NuGet, Maven, or NPM, I have unfortunately encountered instances where updates to my package inadvertently disrupted backwards compatibility. For instance, there wa ...

Retrieve information stored in cookies beyond the component's scope

I've developed a Next.js application with Strapi serving as both the CMS and authentication server. After successfully obtaining a JWT from the authentication endpoint, I have stored it in a cookie. To access secure content from Strapi, I must include ...

The error message from AWS S3 reads: "An issue occurred during the call chain: Unable to process the request (invalid syntax: line 1, column 0), received malformed XML."

Currently, in my local environment, I am utilizing node.js to upload an image to my S3 bucket using localstack. Here is the snippet of API code I am working with: const s3 = new AWS.S3({ accessKeyId: 'testKEYId', secretAccessKey: 'testS ...

Troubleshooting Email Communication Errors: A Persistent Challenge

I am new to nodemailer and trying to work on a simple application. However, I keep encountering errors within the nodemailer module when running my app. Here is my app.js code: const nodemailer = require('nodemailer'); const transporter = node ...

AngularJS faces issue with view not reflecting changes made to model

A web-based game I am developing lets players bid on cards and trade them with one another. The technology stack for this application includes Node, Express, MongoDB, and Angular. The player avatars and names, along with their connection status, are displ ...

Unable to utilize the fetch method in Node.js for sending the API request

I am currently using fetch to send a POST request and retrieve data from an API on the server side (using nextjs 13 + node 18). Interestingly, I can successfully retrieve the data using postman and axios, but not with fetch. Below is the snippet of code ...

Is there a way for me to resume my course of action once a middleware invokes next

Utilizing the express-ip-access-control tool is essential for my ACL verification process. The middleware function I've created looks like this: const ipAccessControl = require('express-ip-access-control') function accessControl (req, res, ...

Issue with a variable within an *.ejs file

Currently, I am following a guide found at this link, and everything is working smoothly except when I encounter an error on the login screen: ..... 7| >> 8| <% if (message != null) { %> 9| <%= message %> 10| <% } %> 11| message is not defined ...

Passing data between pages in Node.js/Express without disrupting the flow of RESTful routing

Within my Express app, the initial landing page prompts visitors to input their email address and then choose between "Sign Up" or "Log In", depending on whether they have an existing account. Following this input, users are directed to either "/signup" o ...

generate dynamic custom headers in an express application for accessibility by an Angular application

https://i.stack.imgur.com/6jyNE.pngRecently, I have started using Express and despite my extensive research, I haven't been able to find a solution to my issue. The problem is that I am receiving headers in my Express app, but when I attempt to make t ...

Gulp: optimizing task creation and mastering series and parallel execution #2732

I've encountered a strange issue with Gulp that I can't seem to figure out. Despite my attempts to understand and utilize it properly, I keep running into roadblocks when trying to work with multiple environments and templates in my application. ...