Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: primordials is not defined #69

Closed
BKeyport opened this issue Oct 2, 2023 · 39 comments
Closed

ReferenceError: primordials is not defined #69

BKeyport opened this issue Oct 2, 2023 · 39 comments
Labels
bug Something isn't working fixed

Comments

@BKeyport
Copy link

BKeyport commented Oct 2, 2023

install.log

@soldatino13
Copy link

same error:

`evalmachine.:43
} = primordials;
^

ReferenceError: primordials is not defined
at evalmachine.:43:5
at Object. (/usr/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at require (node:internal/modules/helpers:130:18)
at Object. (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
`

@raffaelloit
Copy link

Same error here...


Check current NPM installation ...
NPM currently installed. Checking version number.
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)

Node.js v20.5.1
Minimum npm version: V10.1.0
Installed npm version: V
npm should be upgraded.
npm upgrade defered, doing test run  ...

@papinist
Copy link

papinist commented Oct 2, 2023

Instructions say that this error was solved, but me too get all these "primordials is not defined" errors, even with the 'force' option.

@sdetweil
Copy link
Owner

sdetweil commented Oct 2, 2023

ok will look at shortly

@raffaelloit
Copy link

raffaelloit commented Oct 2, 2023

Correction: After running the following script bash -c "$(curl -sL https://raw.githubusercontent.com/sdetweil/MagicMirror_scripts/master/node20_install.sh)"
, the update could be performed without problems. Thanks for the support.

@sdetweil
Copy link
Owner

sdetweil commented Oct 2, 2023

@papinist can you show me the output of

lsb_release -a

@BKeyport
Copy link
Author

BKeyport commented Oct 2, 2023

Fresh Pi Image using latest software - straight to install script:

Installing Node.js ...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfuse2
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 27.0 MB of archives.
After this operation, 183 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_20.x bullseye/main armhf nodejs armhf 20.5.1-deb-1nodesource1 [27.0 MB]
Fetched 27.0 MB in 5s (5,311 kB/s) 
Selecting previously unselected package nodejs.
(Reading database ... 106601 files and directories currently installed.)
Preparing to unpack .../nodejs_20.5.1-deb-1nodesource1_armhf.deb ...
Unpacking nodejs (20.5.1-deb-1nodesource1) ...
Setting up nodejs (20.5.1-deb-1nodesource1) ...
Processing triggers for man-db (2.9.4-2) ...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
nodejs is already the newest version (20.5.1-deb-1nodesource1).
The following package was automatically installed and is no longer required:
  libfuse2
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Node.js installation Done! version=v20.5.1
Check current NPM installation ...
NPM currently installed. Checking version number.
Minimum npm version: V10.1.0
Installed npm version: V9.8.0
npm should be upgraded.
Installing npm ...
E: Unable to correct problems, you have held broken packages.
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=0.8', npm: '1' },
npm WARN EBADENGINE   current: { node: 'v20.5.1', npm: '9.8.0' }
npm WARN EBADENGINE }
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)

Node.js v20.5.1
npm installation Done! version=V
Cloning MagicMirror ...
Cloning into 'MagicMirror'...
remote: Enumerating objects: 376, done.
remote: Counting objects: 100% (376/376), done.
remote: Compressing objects: 100% (311/311), done.
remote: Total 376 (delta 69), reused 200 (delta 49), pack-reused 0
Receiving objects: 100% (376/376), 427.18 KiB | 2.19 MiB/s, done.
Resolving deltas: 100% (69/69), done.
Cloning MagicMirror Done!
Installing dependencies ...
bash: line 452: [: -ge: unary operator expected
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)

Node.js v20.5.1
Unable to install dependencies! 

@BKeyport
Copy link
Author

BKeyport commented Oct 2, 2023

Install will work if you run the node 20 installer script first, but throws repeated: "(node:7940) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit"

@sdetweil
Copy link
Owner

sdetweil commented Oct 3, 2023

yes I see the maxlisteners thing too.

but I fixed the install and upgrade again to include the node20..

@BKeyport
Copy link
Author

BKeyport commented Oct 3, 2023

Indeed - it does seem to be working normally again, other than the maxlisteners thing.

@BKeyport
Copy link
Author

BKeyport commented Oct 3, 2023

Found and fixed my Mirror completely. Only weird thing is that PM2 will start up with everything stopped...

@papinist
Copy link

papinist commented Oct 3, 2023

Now it worked for me too, thank you!

@nibblerrick
Copy link

Same problem here, even when running the node20 script before and when applying force to the upgrade script.

No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

And the error:

Node currently installed. Checking version number.
Minimum Node version: v20.8.0
Installed Node version: v20.8.0
No Node.js upgrade necessary.
Check current NPM installation ...
NPM currently installed. Checking version number.
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.8.0
Minimum npm version: V10.1.0
Installed npm version: V
npm should be upgraded.
Installing npm ...
E: Unable to correct problems, you have held broken packages.
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.8.0
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.8.0
npm installation Done! version=V

force: line 349: [: -ge: unary operator expected
saving custom.css
upgrading from version 2.25.0 to 2.25.0
fetching latest revisions
updating MagicMirror runtime, please wait
force: line 589: [: -ge: unary operator expected
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.8.0
Checking for modules with removed libraries
processing dependency changes for active modules with package.json files

processing for module MMM-Remote-Control please wait
----------------------------------
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.8.0
processing complete for module MMM-Remote-Control

processing for module MMM-Wallpaper please wait
----------------------------------
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.8.0
processing complete for module MMM-Wallpaper

processing for module MMM-MQTTbridge please wait
----------------------------------
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.8.0
processing complete for module MMM-MQTTbridge

processing for module MMM-homeassistant-sensors please wait
----------------------------------
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)

Node.js v20.8.0
processing complete for module MMM-homeassistant-sensors

restoring custom.css

@sdetweil
Copy link
Owner

sdetweil commented Oct 5, 2023

where did u get bookworm from? I don't see that on the download page.
https://www.raspberrypi.com/software/operating-systems/

is this 64bit?

post output of
uname -a

@nibblerrick
Copy link

I did an in-place-upgrade. I've forgotten that raspbian (or now raspberry pi os) isn't debian, I am mostly just used to debian itself...
Linux mm-ab-1 5.10.103-v7l+ #1529 SMP Tue Mar 8 12:24:00 GMT 2022 armv7l GNU/Linux
So 32 bit here.

@sdetweil
Copy link
Owner

sdetweil commented Oct 5, 2023

download the node20_install.sh script

curl -sL https://raw.githubusercontent.com/sdetweil/MagicMirror_scripts/master/node20_install.sh >node20_install.sh
edit the node20_install.sh
and change

NODE_MAJOR=20

to

NODE_MAJOR=18

and run it locally
./node20_install.sh

let me know

do NOT try to run my upgrade script as it is still forcing node20... lets get thru this first...

@nibblerrick
Copy link

Thanks, node18 now installed, pm2 logs says:

/home/pi/.pm2/logs/MagicMirror-error.log last 15 lines:
0|MagicMir |     ^
0|MagicMir | 
0|MagicMir | ReferenceError: primordials is not defined
0|MagicMir |     at evalmachine.<anonymous>:43:5
0|MagicMir |     at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
0|MagicMir |     at Module._compile (node:internal/modules/cjs/loader:1256:14)
0|MagicMir |     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
0|MagicMir |     at Module.load (node:internal/modules/cjs/loader:1119:32)
0|MagicMir |     at Module._load (node:internal/modules/cjs/loader:960:12)
0|MagicMir |     at Module.require (node:internal/modules/cjs/loader:1143:19)
0|MagicMir |     at require (node:internal/modules/cjs/helpers:119:18)
0|MagicMir |     at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
0|MagicMir |     at Module._compile (node:internal/modules/cjs/loader:1256:14)
0|MagicMir | 
0|MagicMir | Node.js v18.18.0

Looks like the same as before.

@sdetweil
Copy link
Owner

sdetweil commented Oct 5, 2023

ok, now do this

pm2 stop all
cd ~/MagicMirror
rm -rf node_modules
npm run install-mm

then

npm start

@sdetweil sdetweil closed this as completed Oct 5, 2023
@nibblerrick
Copy link

Hi,

in my MagicMirror directory there isn't a node_modules file or folder and nom run install-mm gives the already known error:

pi@mm-ab-1:~/MagicMirror $ ls
0             Collaboration.md  css         installers      jsconfig.json  module-types.ts    README.md     splashscreen  vendor
CHANGELOG.md  config            fonts       jest.config.js  LICENSE.md     package.json       run-start.sh  tests
clientonly    core              index.html  js              modules        package-lock.json  serveronly    translations
pi@mm-ab-1:~/MagicMirror $ rm -rf node_modules
pi@mm-ab-1:~/MagicMirror $ ls
0             Collaboration.md  css         installers      jsconfig.json  module-types.ts    README.md     splashscreen  vendor
CHANGELOG.md  config            fonts       jest.config.js  LICENSE.md     package.json       run-start.sh  tests
clientonly    core              index.html  js              modules        package-lock.json  serveronly    translations
pi@mm-ab-1:~/MagicMirror $ npm run install-mm
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)

Node.js v18.18.0

@sdetweil sdetweil reopened this Oct 5, 2023
@sdetweil
Copy link
Owner

sdetweil commented Oct 5, 2023

yeah you're failing on install. man I don't understand why they make this so hard.

@nibblerrick
Copy link

I'll try to get some time to make a new raspbian install, new MM install and try to swap the actual settings to the new install to see if it makes a difference.

@sdetweil
Copy link
Owner

sdetweil commented Oct 6, 2023

@nibblerrick there is another 'test' thing to try

which ever exists

cd /usr/lib/node_modules/npm   
or 
cd /usr/local/lib/node_modules/npm

then

grep version node_modules/graceful_fs  (should NOT say 4.2.11 but 3. something
npm install graceful_fs@latest
grep version node_modules/graceful_fs   (should say 4.2.11)
node -v

@nibblerrick
Copy link

Sure. (graceful-fs instead of graceful_fs, right?)
/usr/local/lib/node_modules/npm:

pi@mm-ab-1:~ $ cd /usr/local/lib/node_modules/npm
pi@mm-ab-1:/usr/local/lib/node_modules/npm $ grep version node_modules/graceful-fs/*
node_modules/graceful-fs/package.json:  "version": "3.0.2",
node_modules/graceful-fs/polyfills.js:    process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
node_modules/graceful-fs/README.md:* fixes `lchmod` for Node versions prior to 0.6.2.
grep: node_modules/graceful-fs/test: Is a directory
pi@mm-ab-1:/usr/local/lib/node_modules/npm $ npm install graceful_fs@latest
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)

Node.js v18.18.0
pi@mm-ab-1:/usr/local/lib/node_modules/npm $ npm install graceful-fs@latest
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)

Node.js v18.18.0

/usr/lib/node_modules/npm:

pi@mm-ab-1:/usr/local/lib/node_modules/npm $ cd /usr/lib/node_modules/npm   
pi@mm-ab-1:/usr/lib/node_modules/npm $ grep version node_modules/graceful-fs/*
node_modules/graceful-fs/graceful-fs.js:  // This is used in testing by future versions
node_modules/graceful-fs/graceful-fs.js:  // Patch fs.close/closeSync to shared queue version, because we need
node_modules/graceful-fs/graceful-fs.js:    var go$readdir = noReaddirOptionVersions.test(process.version)
node_modules/graceful-fs/graceful-fs.js:  if (process.version.substr(0, 4) === 'v0.8') {
node_modules/graceful-fs/graceful-fs.js:    // entries that are only a length of 2 are from an older version, don't
node_modules/graceful-fs/package.json:  "version": "4.2.11",
node_modules/graceful-fs/package.json:    "preversion": "npm test",
node_modules/graceful-fs/package.json:    "postversion": "npm publish",
node_modules/graceful-fs/polyfills.js:      process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
node_modules/graceful-fs/polyfills.js:    // Older versions of Node erroneously returned signed integers for
node_modules/graceful-fs/polyfills.js:    // Older versions of Node erroneously returned signed integers for
pi@mm-ab-1:/usr/lib/node_modules/npm $ npm install graceful-fs@latest
evalmachine.<anonymous>:43
} = primordials;
    ^

ReferenceError: primordials is not defined
    at evalmachine.<anonymous>:43:5
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/fs.js:11:8)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:3:27)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)

Node.js v18.18.0

(makes no difference if I use sudo)

@sdetweil
Copy link
Owner

sdetweil commented Oct 6, 2023

so another piece of advice is wrong.

sorry, have to rebuild the SD card
run my mm install script first
make sure node & npm work
node -v
npm -v
then restore the mm config

@nibblerrick
Copy link

I'll do that, hopefully this weekend.
Let you know then if it resolves the weird issue or not.
Thanks for your help!

@nibblerrick
Copy link

So some news: I made a new SD-Card and then ran your install-script. Same error. node20 script and then install, same.
But I noticed then, that I managed accidentally to install 64 bit and nodejs couldn't be installed that way as with arch=aarch64 in the node sources.list it has broken dependencies.
I removed then the MagicMirrorfolder and nodejs again, changed your script in line 211 and removed the $arch.
After that it ran fine, restored my config, MM now online and working again.
I now wonder what's in the node sources.list file of the earlier install. I'll look for another pi, because I have the old SD card, then I can try to investigate if there's more to find.

@sdetweil
Copy link
Owner

sdetweil commented Oct 9, 2023

I do not add aarch64, only arm64.

@sdetweil
Copy link
Owner

sdetweil commented Oct 9, 2023

this is the issue I opened in the node distro project
nodesource/distributions#1679

@nibblerrick
Copy link

Sorry, was arm64, not aarch64.
Thanks for the linked issue, so 64bit seems to have a problem at the moment.
When I ran the script the first time on the new machine and the primordials error occured that could be because of the wrong node version then.
I just looked at the old sd-card, there isn't any arch and node is installed fine, so there's something else, maybe bookworm.
Probably not worth searching further on the old installation as for normal installs the bug seems solved and the 64bit thing is something else.

@nibblerrick
Copy link

I checked the raspberry imager and for 64 bit I need to explicitly choose that. So I was confused, because I should have running a 32 bit system, but uname -m states aarch64.
I searched and found this - so on rpi4 the default seems to be now a 64bit kernel, but the system is 32bit. May that explain why the nodesources.list with arch=arm64 fails, but without runs fine?

@sdetweil
Copy link
Owner

sdetweil commented Oct 9, 2023

interesting.. I don't use the pi imager as it crashes on my amd desktop.. so I use the balana etcher
https://etcher.balena.io/

and download the image manually

I only get the 64 bit kernel when I specifically flash that image

@nibblerrick
Copy link

If I understand correctly it not only happens when flashing with the rpi-imager but can also happen when just apt update && apt upgrade.
But it looks there's another way to differentiate:
32bit:

pi@mm-ab-1:~ $ uname -m
aarch64
pi@mm-ab-1:~ $ dpkg --print-architecture
armhf

64bit:

pi@BarcodeScreen:~ $ uname -m
aarch64
pi@BarcodeScreen:~ $ dpkg --print-architecture
arm64

Probably dpkg --print-architecture is a more secure way to determine if 32 or 64bit packages?

@sdetweil
Copy link
Owner

sdetweil commented Oct 9, 2023

thanks..

@nibblerrick
Copy link

I have to thank you for these excellent scripts which have saved me much time and are so convenient!

@sdetweil
Copy link
Owner

see these updated scripts too..

https://forum.magicmirror.builders/topic/18072/install-upgrade-scripts-changed-for-version-2-25-and-node-20

@camillemarius
Copy link

Your "testit" branch has fixed the problem described earlier, which I also experienced. MM is now back online and working smoothly. Thank you!

@sdetweil
Copy link
Owner

@camillemarius @nibblerrick the testit branch has been merged back to master..
thanks for your patience and help..

@sdetweil sdetweil added bug Something isn't working fixed labels Oct 14, 2023
@sdetweil
Copy link
Owner

can we close this now?

@nibblerrick
Copy link

Sorry for getting back so late, from my end this can be closed, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

7 participants