简体   繁体   中英

Cannot find module 'express' on cpanel

I tried to setup nodejs on a cpanel nodejs app. I put my package.json on my /games folder, and when I do run npm install, the folder node_modules is created but when I launch my app and go to my link (falsegames.com/game), I am getting an error.

I already tried to place my real folder node_modules instead of the one created by cpanel but it still didnt worked. The error is cannot find module express but it is in my package.json file.

JSON截图

My server.js:

const game = require("./board");


const express = require('express');
const util = require('util');
let app = express();
//var http = require('http').Server(app);
//var io = require('socket.io')(http);
var port = process.env.PORT || 8080;
console.log(window.location)
console.log(window.location.href)
var matched = false;
var rps = {
    checker: 0
}
app.use(express.static('public'));

app.get('/', function (req, res) {
    // nbroom
    res.sendFile("public/index.html");    
}); 
let server = app.listen(port, function () {
    console.log("En écoute sur http://127.0.0.1:"+port);
});
const io = require('socket.io').listen(server).sockets;

// var connections = 0;
var start = 0;
var partialBoards = {}
var boards = {};
var matchmakingboard = null;

let nbroom = 0;

The error i am getting on the website is 'Web application could not be started by the Phusion Passenger application server.' When i go on the terminal then doing node server after entering the virtual environnement im getting error: could not find mondule server.js

您必须将模块保存在依赖项中。

npm install --save module_name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM