The NodeJS external session does not return a value

I have set up my NodeJS session and performed the following test.

test = 1 + 1

returns 2


returns 2

But when I enter


I receive the following error

    "FailureCode" -> "Fault",
"MessageTemplate" -> "RangeError: The maximum size of the call stack has been exceeded",
"Traceback" -> "..."

Please help me solve this problem. Maybe because the output is too big. Btw it works fine on the nodejs console.

What order to follow in JavaScript and Node.JS studies?

Good night guys!

I study javascript by focusing on Node.JS, and realize that I often get lost with basic elements of the language. I believe that I have studied the content in a wrong way.

Could someone help me with the order of studies that I should follow regarding javascript and Node?

node.js – Fusion of php docker images and Nodejs for a development-ready php image, used for development of php applications and CIs

For my application, I have to provide an image that will be used to develop and publish my php application. Also note that a php application for the front-end requires tools such as swallow Webpack etc etc so offering an image with them with php-fpm would be beneficial for rapid development and construction.

But these tools also mainly require node.js and the npm tool and they can be proposed via the node.js image. So I thought the following:

Fusion of Node.js and a php image

In other words, I thought of creating a basic php image containing the required extensions, then from it, to create two other images:

  • A development image containing the necessary tools for application and development by merging some 2 Node.js images and the basic php image one way or another.

  • Production ready images containing the application and the bare minimum to be able to execute it.

In addition, the base image will also use these images:

So I wanted to know:

  • Does this logic make sense, is considered a good idea and a best practice in this case?
  • Is it plausible to merge 2 existing images into a 1 or should I manually install node.js as well?

node.js – Add a review for NPM sem sudo

You are here for you, it's the best idea possible sudo

MacBook-Air-of-Alan: ~ Collins $ npm i -g react-native-cli
npm WARN checkPermissions Missing write access in /Users/collins/.npm-global/lib/node_modules/react-native-cli
npm WARN checkPermissions Missing write access in /Users/collins/.npm-global/lib/node_modules
npm ERR! path /Users/collins/.npm-global/lib/node_modules/react-native-cli
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: Permission Denied, navigate to & # 39; /Users/collins/.npm-global/lib/node_modules/react-native-cli&#39;
npm ERR!  [Error: EACCES: permission denied, access '/Users/collins/.npm-global/lib/node_modules/react-native-cli'] {
npm ERR! Stack: "Error: EACCES: permission denied, access & # 39; +
npm ERR! "& # 39; /Users/collins/.npm-global/lib/node_modules/react-native-cli&#39;"
npm ERR! errno: -13,
npm ERR! code: "EACCES",
npm ERR! system call: & # 39;
npm ERR! path: & # 39; /Users/collins/.npm-global/lib/node_modules/react-native-cli&#39;
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely that you do not have the necessary permissions to access this file as the current user.
npm ERR!
npm ERR! If you think this could be a licensing issue, please double check the
npm ERR! permissions of the file and its directories, or try to execute
npm ERR! the command again as root / administrator (although this is not recommended).

npm ERR! A complete diary of this run can be found in:
npm ERR! /Users/collins/.npm/_logs/2019-06-13T22_24_55_458Z-debug.log

node.js – Publish a file with Axios

const form_data = new FormData ();
form_data.append ("File", fs.createReadStream (pathToFile));
form_data.append (& # 39; Login & # 39 ;, alias.toUpperCase ());

const request_config = {
headers: {
"Authorization": "Basic 123",
"Content-Type": application / x-www-form-urlencoded & # 39;
data: form_data

wait (url, params, request_config) .then (response => {

Publish to a point, I can not debug. The error I get from the server is "The connection is missing".

Is this the right way to do it? The server requires a application / x-www-form-urlencoded

Can I see exactly what Axios sends?

javascript – Get the value of a nodejs function

I need to get the value of the variable "token" and use it in another function. (NodeJS)

const axios = require (axios & # 39;)
/ *

* /
asynchronous function getToken () {

const presetToken = {
method: "GET",
url: url & # 39;

let getToken = wait axios (presetToken)
token var = getToken.headers
return token

console.log ("The token is" + getToken ())

node.js – axios responce does not have complete headers



in the images above you will see that I will receive an answer
but by getting headers with res.header ("auth-token")
I will not receive a token

customer side

axios ({
method: "post",
data: data,
url: "" + choice,
headers: {
"Access-Control-Expose-Headers": "Access Token, Uid",
"Access-Control-Allow-Origin": "*",
"Access-Control-Request-Headers": "authentication token, content type"
.then (res => {
if (res.status === 200) {
console.log (res);
this.setState ({
formErrors: {
First name: "",
Last name: "",
E-mail: "",
Confirm your email: "",
password: ""
console.log (res.header ("auth-token"));
.catch (err => {
if (typeof err! = "undefined" && typeof err.response! = "undefined") {
if (err.response.status === 400) {
console.log (;
this.setState ({formErrors:});
} other {
alert ("Something is wrong");

on the server side

let user = new users ();
user.firstName = req.results[0].First name;
user.lastName = req.results[0].Last name; = req.results[0].E-mail;
token of const = user.generateAuthToken ();
res.setHeader ("auth-token", token);
const t = res.header ("auth-token");
console.log (t);
return res.status (200) .send (user);

How to configure a Node.js application for production on a CentOS VPS 7

In this tutorial we will create a simple Node.js application and place it in an environment ready for production. We will install and use the following software:

  • Nginx as a reverse proxy. The application will be accessible from your browser. If you use multiple sites from the same server, it could also serve as a load balancer.
  • Certbot we will let Let Encrypt's certificates be installed. The access to the site will be secure because only HTTPS requests will be honored.
  • NPM package called PM2 will turn a node.js application into service. The application will run in the background, even after a crash or reboot of the system.

What we are going to cover

  • Install Nginx
  • Install firewall-cmd and activate the rules for Nginx
  • Install the latest version of Node.js
  • Add NPM packages for the application we make
  • Create the sample application to display all characters in uppercase
  • Configure Nginx as a reverse proxy
  • Install Let's Encrypt Certificates to Meet HTTPS Requests
  • Access the application from the browser
  • Install PM2, a production process manager for Node.js applications with a built-in traffic balancer
  • Use PM2 to restart the Node.js application every time the system reboots or reboots.


We use Centos 7:

  • Starting with a clean VPS with
  • At least 512 MB of RAM and
  • 15 GB of available disk space.
  • You will need a root user access via SSH
  • A domain name pointing to the IP address of your server (it can also be a subdomain) using A records from your DNS service provider.
  • We use nano as an editor of your choice, and you can install it with this command:
yum install nano

Step 1: Install Nginx

After logging in as a root user, you will install Nginx. Add the CentOS 7 EPEL repository with this command:

yum install epel-release

Then install Nginx:

yum install nginx

Press 'y' twice and the installation will be complete. Enable the Nginx service to start at server startup:

systemctl enable nginx

Step 2: Change Firewall Rules to Enable Nginx

Now let's install firewall-cmd, the front-end command line for firewall (firewalld daemon), for CentOS. It supports both IPv4 and IPv6, firewall zones, bridges and IPsets, allows the inclusion of timed firewall rules in zones, logs refused packets , automatically loads kernel modules, etc.

Install it in the usual way, using yum:

yum install firewalld

Let's start now, enable the automatic start at system startup and see its status:

systemctl start firewalld
systemctl enable firewall
systemctl status

Node.js applications require a port that is not used by the system, but is dedicated to this application only. In our examples, we could use ports such as 3000, 8080, etc., so we have to explicitly declare them, otherwise the application will not work.

Here is a list of ports and do not hesitate to add the others that your host needs for the normal operation of the system:

firewall-cmd --permanent --zone = public --add-service = ssh
firewall-cmd --zone = public --add-port = 3000 / tcp --permanent
firewall-cmd --zone = public --add-port = 8080 / tcp --permanent
firewall-cmd --permanent --zone = public --add-service = http
firewall-cmd --permanent --zone = public --add-service = https
firewall-cmd --reload

Let's start now Nginx:

systemctl start nginx

With the operation of HTTP, we can visit this address in the browser:

http: // YOUR_DOMAIN /

and check that Nginx is running:

Step 3: Install Latest Node.js

We will now install the latest version of Node.js. First, install development tools to create native add-ons (make, gcc-c ++) then enable the yum Node.js repository from the official Node.js site:

yam install -y gcc-c ++ do
curl -sL | sudo -E bash -

Now the repository is added to your VPS and we can install the Node.js package. NPM, the package manager for Node.js, will also be installed, along with many other system dependent packages.

yum install nodejs

Press 'y' twice to complete the installation. View the version of Node.js installed:

node -v

It shows v12.3.1, which was the actual version at the time of writing this article. If an error is displayed, recheck the commands you have entered with those listed above.

Step 4: Adding NPM Packages

Of course we know which packages our Node.js application will need, so we have installed the required npm packages in advance. Since our application will turn any input into uppercase letters, we first install a package for it:

npm install the capital letters

Most Node.js applications will now use Express.js, let's install it too:

npm install --save express

Also run this command:

npm install -g nginx-generator

It will globally install a NPM package to generate the reverse proxy configuration for Nginx. We will apply it once the application runs on port 8080.

Step 5: Creating the application

Open a file named shift-http.js for editing:

nano uppercase-http.js

Add the following lines:

var http = require (& # 39; http & # 39;);
var uc = require (& # 39; uppercase & # 39;);
console.log (& # 39; starting ...);
http.createServer (function (req, res) {
console.log (& # 39; request received for the URL: & # 39; + req.url);
res.writeHead (200, {Content-Type: text / html});
res.write (uc (req.url + # 39;  n & # 39;));
res.end ();
}). listen (8080);

Save and close the file.

The HTTP server listens on port 8080. You can specify any other port of your choice, as long as it is free while the application is running (and you have previously opened it). access in the application. firewall).

Start the application:

capitalized node-http.js

You will see the following message:


Node.js app from

To test it, start another terminal, connect to your VPS as root via SSH and curl localhost: 8080:

curl localhost: 8080 / test

The program correctly converts the path to uppercase. The server application displays a status message for the request:

request received for url: / test

We now have two terminal windows, one with the application running and the other with which we have tested the application. The first window is blocked as long as the application is running and you can press Ctrl-C from the keyboard to stop it. If we do, the application will not work later when we access it from the browser. The solution is to re-enable the application or, even cleaner, to enter other commands only in the second terminal window for the rest of this tutorial.

Step 6: Configure Nginx as Reverse Proxy

Nginx for CentOS comes without folders for available and activated sites, as is the case on Ubuntu Linux. You will have to create them:

mkdir / etc / nginx / sites-available
mkdir / etc / nginx / sites-enabled

Then, edit the global configuration of Nginx to load the configuration files from these folders:

nano /etc/nginx/nginx.conf

Find a line

include /etc/nginx/conf.d/*.conf;

and insert these lines:

include / etc / nginx / sites-enabled / *;
hash_bucket_size_server_name 64;

Save and close the file. Nginx will now read the content of the "activated" sites.

For the sake of completeness, our nginx.conf The file looks like this:

nginx user;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/;

events {
worker_connections 1024;

http {
include /etc/nginx/mime.types;
default_type application / octet-stream;

log_format main $ remote_addr - $ remote_user [$time_local] "$ request" & # 39;
& # 39; $ status $ body_bytes_sent "$ http_referer" & # 39;
& # 39; "$ http_user_agent" "$ http_x_forwarded_for" & # 39 ;;

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
include / etc / nginx / sites-enabled / *;
hash_bucket_size_server_name 64;

You may want to copy and paste it.

With NPM package nginx generator we generate files that will tell Nginx to act as a reverse proxy. In the command line, perform the following:

--name site_nginx 
--domain YOUR_DOMAIN 
--type proxy 
--var host = localhost 
--var port = 8080 
/ etc / nginx / sites-enabled / site_nginx

Replace YOUR_DOMAIN with your current domain before running this command.

This command creates a file called site_nginx and place it in the / etc / nginx / sites-enabled / directory. (We could have used another name instead of site_nginx for the file.)

We can see it with this command:

sudo nano / etc / nginx / sites-enabled / site_nginx

Test the configuration:

sudo nginx -t

and hopefully, restart Nginx:

systemctl restart nginx

Run the application again:

capitalized node-http.js

You will see the following message:


In your browser, go to the address

http: // YOUR_DOMAIN / test

and the result should be


Bad Gateway Case No. 1 – The application is not active

Instead of a correct result, which in this particular case would be a text printed in capital letters, it is too easy to receive the message. Bad gateway in this location.

The main reason is that we use a central window to run the application and to insert other commands. When you start the application with capitalized node-http.js, the application stops. It blocks the entire window, and when you want to try the next command of the installation process, the application stops. One way to avoid this is to start over again, as we did in this tutorial.

Another solution would be to open two terminal windows, launch the application in one of them, and then execute additional commands in the second window of the terminal, exclusively.

Incorrect gateway case # 2 – SELinux is active

If SELinux is enabled, it can prevent Nginx from making outgoing connections.

You can check this with:

get strength

If you get L & # 39; app SELinux is therefore active. Run this command to let Nginx serve as a reverse proxy:

setsebool -P httpd_can_network_connect true

Step 7: Secure your site to only use HTTPS

We want to serve our application via an HTTPS request. If you have a domain name and properly configured DNS records to point to your VPS, you can use certbot to generate Let's Encrypt certificates. This means that you will always have access to the application as well as to the rest of your domain via HTTPS.

We will follow the original documentation to install Let's Encrypt. Choose Nginx for Software and Centos / RHEL 7 for System – it should look like this:

Certbot Certbot Site "width =" 524 "height =" 323

Certbot is packaged in EPEL (Extra Packages for Enterprise Linux). To use Certbot, you must first activate the EPEL repository. On CentOS, you must also enable the optional channel by running the following commands:

yum y-install yum-utils
yum-config-manager --enable rhui-REGION-server-rhel-extras rhui-REGION-server-rhel-optional

Now, install the Certbot by running this:

yum install certbot python2-certbot-nginx

He will calculate the necessary dependencies and ask you to let him proceed with the installation.

Press 'y' when prompted.

Finally, launch Certbot:

certbot --nginx

If you are installing certificates for the first time, Certbot will ask you for an emergency e-mail address, then several less important questions, and finally – do you want to redirect all HTTP traffic to HTTPS? Select 2 to confirm this redirect and you are all together!

Activate Nginx as you normally would after each parameter change:

systemctl restart nginx

To verify that the redirection works, go to the same address in your browser:

https: // YOUR_DOMAIN / test

Note that this address started with HTTP, but that it eventually ended under HTTPS.

Step 8: Install PM2

PM2 is a production process manager for Node.js applications. With PM2, we can monitor applications, their memory and processor usage. It also provides easy commands to stop / start / restart all applications or individual applications.

Once the application is started via PM2, it will always be restarted after a system crash or reboot. Indeed, he will be "always there".

Use NPM to install PM2:

npm install pm2 @ latest -g

Option -g tells it to install pm2 globally, so that it can run from all system paths.

Let's launch our application under PM2 now:

pm2 start capital-http.js

The output of PM2 can be spectacular when first used, but we really need to focus on the lines of the application:

PM2 will use the name of the application, then show the login application number, mode, status, CPU usage and memory. If two or more applications are running in the background, they will all be shown in this table.

We can list processes like this:

pm2 list

The following command

pm2 show 0

will display the details of the application with ID 0:

It is also possible to monitor CPU usage in real time:

pm2 monit

Other useful PM2 commands are stop, to restart, wipe off.

What can you do next?

You now have a node.js application in a production environment, using the HTTPS protocol for security, Nginx for speed, and as a reverse proxy, running as a background service. We have just installed an application and a site of this type, while you can run applications and serveral sites node.js from the same server. We used root user for ease of installation, while for multiple sites, you will need multiple non-root users for security reasons.

Dusko Savic is a technical writer and programmer.

How to use console.log () in the new NodeJS external language cell feature in Ver12

If I type the following
enter the description of the image here

Mathematica does not return anything asking for information[Sembleindiquerquel%}&#39;aéchouéJoperation$&#39;airegardélafenêtredesmessagesdanslafenêtreduterminalrienn&#39;estsorti?[%}Seemstoindicatethattheoperation$FailedIhavelookedatthemessageswindowintheterminalwindownothingisoutput?[%}sembleindiquerquel'opération$aéchouéJ'airegardélafenêtredesmessagesdanslafenêtreduterminalrienn'estsorti?[%}seemstoindicatethattheoperation$FailedIhavelookedatthemessageswindowintheterminalwindownothingisoutput?

The installation of node.js indicates an invalid key

When I try to install Node, js in Windows 7 x84, the setup program stops and an alert message stating that the key is not valid for the current state of the art.
Help me please