0

To describe my situation a bit:

I am developing a webapp (better to say an Onlineshop), mainly I develop on my Windows Desktop and Push the Code to my server, which runs Ubuntu Server. Its a Nodejs Webapp running on Nginx Webserver inside a Docker container (Database i'm using is Mysql, which is also running inside a Docker container on my server). I have set up git and my project as normal and started to do my thing... On my Windows machine everything went fine and as espected. But after pushing to my Server and running the file I got this error:

raffaelbaer@olympus:~$ /usr/bin/node /home/raffaelbaer/webserver/nodejs/app.js
/home/raffaelbaer/webserver/nodejs/node_modules/lru-cache/dist/cjs/index.js:359
#initializeTTLTracking() {
                      ^

SyntaxError: Unexpected token '('
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/raffaelbaer/webserver/nodejs/node_modules/lru- 
cache/dist/cjs/index-cjs.js:5:36)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

I dont know why this error is happening, I checked everything in the node_modules, but everything seems right.

Maybe its because I'm on different Plattforms? Or I have different Node Versions installed?

I didnt find anything about my Issue online and therefore, I hope to get some help here!

Best Regards Raffael

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • Welcome to Stack Overflow. We'd need more information. 1) What is the version of node locally and on your server? 2) Can we see the code around the syntax error? – Schwern Apr 25 '23 at 17:44

1 Answers1

0

#initializeTTLTracking() { looks like a private instance method. It is relatively new, roughly 2019.

The minimum node version to support the #foo syntax is v12. It's possible the version of node on your server is too old. If you are running Ubuntu 20 the default nodejs is v10.

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • Hey thanks for your fast reply, I just fixed it. My node Versions where both aboth 16.00.00. I just started the app by "node app.js" instead of "/usr/bin/node". I did this with a service, so I dont have to manually restart and it can run in the backround. But I guess by running the path to node, it somehow used the wrong nodejs and it failed, but if I call it without path it works perfectly fine!! Maybe you know what the problem is exactly there, but now its is working... – raffaelbaer Apr 25 '23 at 18:11
  • @raffaelbaer You probably have multiple copies of node installed, perhaps via npm? /usr/bin/node will be the one installed by Ubuntu. `node app.js` says to use the first executable file named node in your PATH. `which node` will tell you what that is. ***However*** your login shell and service launcher may have different PATHs. – Schwern Apr 26 '23 at 02:12
  • @raffaelbaer See https://www.howtogeek.com/devops/what-is-the-unix-path-and-how-do-you-add-programs-to-it/ – Schwern Apr 26 '23 at 02:13