Satakunnan-ammattikorkeakoulu / jobeinabox

The dockerfile and doc for building the Docker image JobeInABox
MIT License
0 stars 0 forks source link

Update nodejs to more later version #5

Open kulttuuri opened 2 months ago

kulttuuri commented 2 months ago

These commands can be used to update nodejs to a later version, add these to the Dockerfile:

apt update
apt install npm wget curl
npm install -g n
n 22.7.0
mv /usr/bin/nodejs /usr/bin/nodejs_old
ln -s $(which node) /usr/bin/nodejs
kulttuuri commented 2 weeks ago

And it will also cause an error about javascript modules. Need to also do this fix, also:

https://coderunner.org.nz/mod/forum/discuss.php?d=707

File: /var/www/html/jobe/application/libraries/nodejs_task.php

Edit:

Original functions:

public function compile() { $this->executableFileName = $this->sourceFileName; if (strpos('.js', $this->executableFileName) != strlen($this->executableFileName) - 3) { $this->executableFileName .= '.js'; } if (!copy($this->sourceFileName, $this->executableFileName)) { throw new exception("Node_Task: couldn't copy source file"); } }

public function getTargetFile() { return $this->sourceFileName; }

And edited functions to make the runnable script be saved as .mjs:

public function compile() { $this->executableFileName = preg_replace('/.js$/', '.mjs', $this->sourceFileName); if (!copy($this->sourceFileName, $this->executableFileName)) { throw new exception("Node_Task: couldn't copy source file"); } }

public function getTargetFile() { return preg_replace('/.js$/', '.mjs', $this->sourceFileName); }