bcrypt-node issue
Opened this issue · 16 comments
Summary
Getting this error on Debian 12
/opt/cronicle/bin/control.sh setup
node:internal/modules/cjs/loader:1137
throw err;
^
Error: Cannot find module 'bcrypt-node'
Require stack:
- /opt/cronicle/bin/storage-cli.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
at Module._load (node:internal/modules/cjs/loader:975:27)
at Module.require (node:internal/modules/cjs/loader:1225:19)
at require (node:internal/modules/helpers:177:18)
at Object. (/opt/cronicle/bin/storage-cli.js:12:14)
at Module._compile (node:internal/modules/cjs/loader:1356:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
at Module.load (node:internal/modules/cjs/loader:1197:32)
at Module._load (node:internal/modules/cjs/loader:1013:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/opt/cronicle/bin/storage-cli.js' ]
}
Steps to reproduce the problem
/opt/cronicle/bin/control.sh setup
Your Setup
NodeJs installed.
bcrypt installed.
Operating system and version?
Debian 12
Node.js version?
Node.js v18.19.0
Cronicle software version?
Single server
Are you using the filesystem as back-end storage, or S3/Couchbase?
No
Can you reproduce the crash consistently?
yes
Log Excerpts
Very odd. The auto-installer should have taken care of this. Did you install manually or something?
https://github.com/jhuckaby/Cronicle/blob/master/docs/Setup.md#installation
Looks like somehow the npm install
command was missed. If you installed using the auto-installer, this SHOULD have happened automatically.
If you installed manually by hand, looks like perhaps a step was missed:
mkdir -p /opt/cronicle
cd /opt/cronicle
curl -L https://github.com/jhuckaby/Cronicle/archive/v1.0.0.tar.gz | tar zxvf - --strip-components 1
npm install # <-- This step here
node bin/build.js dist
Can you try the npm install
command again?
No buddy, i used this command after installing requirements.
curl -s https://raw.githubusercontent.com/jhuckaby/Cronicle/master/bin/install.js | node
That's really strange. Check the install log for errors maybe?
cat /opt/cronicle/logs/install.log
Also, check the /opt/cronicle/node_modules/
folder to see if bcrypt-node
is in there?
ls -l /opt/cronicle/node_modules/bcrypt-node
total 120
-rw-r--r-- 1 root wheel 1481 Nov 11 2022 LICENSE
-rw-r--r-- 1 root wheel 4371 Nov 11 2022 README.md
-rw-r--r-- 1 root wheel 25423 Nov 11 2022 bCrypt.js
-rw-r--r-- 1 root wheel 248 Nov 11 2022 makefile
-rw-r--r-- 1 root wheel 1262 Nov 11 2022 package.json
drwxr-xr-x 4 root wheel 128 Nov 11 2022 test
-rw-r--r-- 1 root wheel 1463 Nov 11 2022 test-async.js
-rw-r--r-- 1 root wheel 4108 Nov 11 2022 test-sync.js
Not sure what else to try. I've never encountered NPM failing to install bcrypt before.
Maybe try running the install command again?
Perhaps it just trying and failing to install some native modules (not using pre-built binaries). You can try to init some blank npm project "npm init -y" and try to install bcrypt there tocheck for errors. You might be missing python or gcc compiler
cat /opt/cronicle/logs/install.log
Starting install run: Tue Dec 03 2024 13:16:02 GMT+0000 (Greenwich Mean Time)
Cronicle Installer v1.5
Copyright (c) 2015 - 2022 PixlCore.com. MIT Licensed.
Log File: /opt/cronicle/logs/install.log
Fetching release list...
Releases URL: https://api.github.com/repos/jhuckaby/Cronicle/releases
Installing Cronicle v0.9.61...
Tarball URL: https://api.github.com/repos/jhuckaby/Cronicle/tarball/v0.9.61
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 335k 0 335k 0 0 121k 0 --:--:-- 0:00:02 --:--:-- 280k
Installing dependencies...
Executing command: npm install --unsafe-perm
/bin/sh: 1: npm: not found
ERROR: Failed to install dependencies: Error: Command failed: npm install --unsafe-perm
/bin/sh: 1: npm: not found
Starting install run: Tue Dec 03 2024 13:30:34 GMT+0000 (Greenwich Mean Time)
Cronicle Installer v1.5
Copyright (c) 2015 - 2022 PixlCore.com. MIT Licensed.
Log File: /opt/cronicle/logs/install.log
Fetching release list...
Releases URL: https://api.github.com/repos/jhuckaby/Cronicle/releases
Version 0.9.61 is already installed, and is the latest.
I get this error for mikes reply.
ls -l /opt/cronicle/node_modules/bcrypt-node
ls: cannot access '/opt/cronicle/node_modules/bcrypt-node': No such file or directory
Ah, here's our problem:
ERROR: Failed to install dependencies: Error: Command failed: npm install --unsafe-perm
/bin/sh: 1: npm: not found
So when you installed Node.js, somehow the NPM binary didn't get installed. It's supposed to come with Node.js, but in this case it didn't go in for some reason.
Try reinstalling Node.js from a package manager maybe?
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
This should install NPM as well as Node.js.
After running
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
I got
/opt/cronicle/bin/control.sh start
/opt/cronicle/bin/control.sh start: Starting up Cronicle Server...
node:internal/modules/cjs/loader:1228
throw err;
^
Error: Cannot find module 'pixl-server'
Require stack:
- /opt/cronicle/lib/main.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
at Module._load (node:internal/modules/cjs/loader:1051:27)
at Module.require (node:internal/modules/cjs/loader:1311:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/opt/cronicle/lib/main.js:13:18)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Module._load (node:internal/modules/cjs/loader:1104:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/opt/cronicle/lib/main.js' ]
}
Node.js v20.18.1
/opt/cronicle/bin/control.sh start: Cronicle Server could not be started
Sorry, I should have clarified. Since Node.js wasn't properly installed on your server (until now), you will have to start over at the beginning, because none of the dependencies were installed by NPM. So, please try the Cronicle install steps one last time:
curl -s https://raw.githubusercontent.com/jhuckaby/Cronicle/master/bin/install.js | node
Then run the setup:
/opt/cronicle/bin/control.sh setup
Then finally you can start the service:
/opt/cronicle/bin/control.sh start
https://github.com/jhuckaby/Cronicle/blob/master/docs/Setup.md#installation
Sorry this is so confusing. I'll try to make this all easier in v2.
I got from jhuckaby
curl -s https://raw.githubusercontent.com/jhuckaby/Cronicle/master/bin/install.js | node
Cronicle Installer v1.5
Copyright (c) 2015 - 2022 PixlCore.com. MIT Licensed.
Log File: /opt/cronicle/logs/install.log
Fetching release list...
Version 0.9.61 is already installed, and is the latest.
Oh dear god, of course. It thinks the latest is installed (it was "half-installed"), so it doesn't try to reinstall, UGH!!!!
What a mess, I'm so sorry 😞
I think we'll need to wipe out the install, so it reinstalls from scratch. If you have customized the /opt/cronicle/config.json
file, please copy this to a temp location:
sudo cp /opt/cronicle/conf/config.json /tmp/
Then wipe it all out:
sudo rm -rf /opt/cronicle
Then finally, you can do the reinstall steps, from the top:
https://github.com/jhuckaby/Cronicle/blob/master/docs/Setup.md#installation
Then you can copy your temp config file back into place, if needed:
sudo mv /tmp/config.json /opt/cronicle/conf/config.json
I'm SO sorry this is so confusing and silly. I will work on improving these installation steps and rewrite the installation documentation, with full Node.js install steps included, so people won't run into this situation in the future.
Huge apologies.
Worked. Legend thank you.
Okay, so this looks like an issue with your firefox-esr
program:
Error: no DISPLAY environment variable specified
I don't know anything about this, but I'm guessing it's some sort of headless browser automation system akin to Puppeteer or Playright?
I threw this over to ChatGPT 4o to get some more insight:
That error indicates that the firefox-esr program is trying to start in graphical (GUI) mode, but it cannot find an active X server to connect to. The DISPLAY environment variable tells graphical applications which display to use for rendering their windows. Without it, graphical programs cannot start.
Fixing the Issue
Option 1: Use xvfb-run to Emulate a Display
If firefox-esr needs to run in a graphical environment, you can use xvfb-run, a utility that provides a virtual framebuffer X server. This allows graphical applications to run headlessly (without a physical display).
Install xvfb (if not already installed):
• On Debian/Ubuntu:
sudo apt-get install xvfb
Then Run your job with xvfb-run:
xvfb-run firefox-esr
Option 2: Use Headless Mode
Modern versions of Firefox (including ESR) support a “headless” mode for running without a graphical environment. Check if your firefox-esr supports this feature by running:
firefox-esr --headless
Option 3: Set the DISPLAY Environment Variable
export DISPLAY=:0
firefox-esr
Good luck!
I keep getting this error on a script thats ran in the past.
If the job ran successfully in the past, I am guessing that Cronicle was previously started with the DISPLAY
environment variable already set. This variable then "stuck" in memory and propagated down to the jobs that it launched. But this time, today, when you reinstalled and restarted Cronicle, you may have been in a different context (i.e. different terminal environment, SSH instead of direct console, etc.). where the environment variable wasn't set.
Adding export DISPLAY=:0
or something like it to your shell script should help, or alternatively you can add environment variables in the job_env
configuration property for ALL jobs to inherit:
https://github.com/jhuckaby/Cronicle/blob/master/docs/Configuration.md#job_env