aktos-io / scadajs-showcase

ScadaJS Template Project
6 stars 1 forks source link

Failed to start server #2

Closed ysdede closed 7 years ago

ysdede commented 7 years ago

I got import errors while trying to run server:

$ ./server.service

Failed at: server.ls
Error: Cannot find module 'express'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/yunus/Desktop/myproject/webserver/server.ls:5:11)
1| // Generated by LiveScript 1.4.0
2| var fs, path, express, webserverPort, pubDir, app, http, ref$, TCPProxyServer, SocketIOServer, db, dcsPort;
3| fs = require('fs');
4| path = require('path');
5+ express = require('express');
6| webserverPort = require('./configuration').webserverPort;
7| pubDir = __dirname + "/../scada.js/build/";
8| app = express();
9| http = require('http').Server(app);
    at Module._compile (module.js:569:30)
    at Object.LiveScript.run (/usr/local/lib/node_modules/livescript/lib/node.js:31:19)
    at compileScript (/usr/local/lib/node_modules/livescript/lib/command.js:199:31)
    at /usr/local/lib/node_modules/livescript/lib/command.js:129:11
    at /usr/local/lib/node_modules/livescript/lib/command.js:119:7

It works succesfully with sudo:

$ sudo ./server.service


root@yubuntu:~/Desktop/myproject# cd webserver
root@yubuntu:~/Desktop/myproject/webserver# lsc server.ls
serving static folder: /
listening on *:4001
625ms: TCPProxyServer  : TCP Proxy Server started on port 5522.
627ms: SocketIO Server : SocketIO server started...
975ms: socketio-1      : >>=== New connection from the client is accepted. name: socketio-1
976ms: SessionCache    : SessionCache is initialized {}
2082ms: socketio-2      : >>=== New connection from the client is accepted. name: socketio-2

It's also OK with running manually:

cd webserver
./run-ls server.ls 
serving static folder: /
listening on *:4001
628ms: TCPProxyServer  : TCP Proxy Server started on port 5522.
630ms: SocketIO Server : SocketIO server started...
3840ms: socketio-1      : >>=== New connection from the client is accepted. name: socketio-1
3840ms: SessionCache    : SessionCache is initialized {}
8113ms: socketio-2      : >>=== New connection from the client is accepted. name: socketio-2
ceremcem commented 7 years ago

server.service is just a tmux wrapper that "manually" runs ./run-ls server.ls. Thus, if manually running server.ls works but server.service fails, it just looks impossible at the first glance.

Can you run echo $NODE_PATH in the tmux terminal where express fails and post the output?

ysdede commented 7 years ago
yunus@yubuntu:~/Desktop/myproject/webserver$ echo $NODE_PATH
/home/yunus/Desktop/myproject/scada.js/node_modules:/home/yunus/Desktop/myproject/scada.js/src/lib: