Bug 2276166

Summary: Corrupts nodejs whenever i download a package via npm
Product: [Fedora] Fedora Reporter: qmxs98xl
Component: nodejs-cjs-module-lexerAssignee: Jan Staněk <jstanek>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 39CC: fedora, jstanek
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-04-20 16:28:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Screenshot of error showing after entering node none

Description qmxs98xl 2024-04-20 01:50:38 UTC
Created attachment 2028017 [details]
Screenshot of error showing after entering node

Description of problem:
If I try to download any package using npm, it will corrupt the nodejs. It will only work after I reinstall nodejs. I tried installing typescript as global package and also tried angular/cli. 

It is giving me error "Cannot load externalized builtin: "internal/deps/cjs-module-lexer/lexer:/usr/lib/node_modules/cjs-module-lexer/lexer.js"."



Version-Release number of selected component (if applicable):
1. nodejs  x86_64  1:20.12.0-1.fc39
2. nodejs-cjs-module-lexer  noarch  1.2.3-2.fc39
3. nodejs-docs              noarch  1:20.12.0-1.fc39
4. nodejs-full-i18n         x86_64  1:20.12.0-1.fc39
5. nodejs-libs              x86_64  1:20.12.0-1.fc39
6. nodejs-npm               x86_64  1:10.5.0-1.20.12.0.1.fc39
7. nodejs-undici            noarch  6.11.1-2.fc39



How reproducible:
Happens everytime I install a package. Tried reinstalling nodejs, updating fedora 39. Still same issue



Steps to Reproduce:
1. `sudo npm i -g @angular/cli` or `sudo npm i -g typescript`
2. `node`



Actual results:

Cannot load externalized builtin: "internal/deps/cjs-module-lexer/lexer:/usr/lib/node_modules/cjs-module-lexer/lexer.js".
----- Native stack trace -----

 1: 0x7fa8138f472e node::builtins::BuiltinLoader::AddExternalizedBuiltin(char const*, char const*) [/lib64/libnode.so.115]
 2: 0x7fa8138f4935 node::builtins::BuiltinLoader::BuiltinLoader() [/lib64/libnode.so.115]
 3: 0x7fa8138418d7 node::InitializePrimordials(v8::Local<v8::Context>) [/lib64/libnode.so.115]
 4: 0x7fa813841a08 node::GetPerContextExports(v8::Local<v8::Context>) [/lib64/libnode.so.115]
 5: 0x7fa8138417e8 node::InitializePrimordials(v8::Local<v8::Context>) [/lib64/libnode.so.115]
 6: 0x7fa813841ae0 node::InitializeMainContextForSnapshot(v8::Local<v8::Context>) [/lib64/libnode.so.115]
 7: 0x7fa813841b05 node::InitializeContext(v8::Local<v8::Context>) [/lib64/libnode.so.115]
 8: 0x7fa813841b63 node::NewContext(v8::Isolate*, v8::Local<v8::ObjectTemplate>) [/lib64/libnode.so.115]
 9: 0x7fa81397c9b4 node::NodeMainInstance::CreateMainEnvironment(node::ExitCode*) [/lib64/libnode.so.115]
10: 0x7fa81397cb0d node::NodeMainInstance::Run() [/lib64/libnode.so.115]
11: 0x7fa8138df351 node::Start(int, char**) [/lib64/libnode.so.115]
12: 0x7fa812c4614a  [/lib64/libc.so.6]
13: 0x7fa812c4620b __libc_start_main [/lib64/libc.so.6]
14: 0x56275d89a035 _start [node]
Aborted (core dumped)




Expected results:

Welcome to Node.js v20.12.0.
Type ".help" for more information.
> 



Additional info:
OS: Fedora Linux 39
Kernel: 6.8.6-200.fc39.x86_64
DE: GNOME 45.5
Shell: bash 5.2.26

Comment 1 Zephyr Lykos 2024-04-20 02:40:13 UTC
This is likely a kernel io_uring bug.

See <https://github.com/nodejs/cjs-module-lexer/issues/92#issuecomment-2066052271>.

Comment 2 qmxs98xl 2024-04-20 04:11:32 UTC
(In reply to Zephyr Lykos from comment #1)
> This is likely a kernel io_uring bug.
> 
> See
> <https://github.com/nodejs/cjs-module-lexer/issues/92#issuecomment-
> 2066052271>.

https://github.com/nodejs/cjs-module-lexer/issues/92#issuecomment-2067541709

I did try to put env variable still facing issues. Do you think changing to fedora 40 will fix it?

Comment 3 Zephyr Lykos 2024-04-20 16:07:26 UTC
Hmm, seems this is another issue.
With `UV_USE_IO_URING=1` the former io_uring shenanigans are still reproducible in rawhide.

Comment 4 Zephyr Lykos 2024-04-20 16:28:47 UTC
OK, I figured this out.

You are running npm as root and your npmrc sets `prefix=/usr`, which overrides `/usr/lib/node_modules` to a folder instead of a symlink.
Please don't install npm packages globally, at least not installing to `/usr/lib`.

Comment 5 qmxs98xl 2024-04-25 04:01:05 UTC
(In reply to Zephyr Lykos from comment #4)
> OK, I figured this out.
> 
> You are running npm as root and your npmrc sets `prefix=/usr`, which
> overrides `/usr/lib/node_modules` to a folder instead of a symlink.
> Please don't install npm packages globally, at least not installing to
> `/usr/lib`.

Issue is that I need to install `@angular/cli` . If I dont install it globally then `ng` command is not working

Things I did
- `npm init`
- `npm i @angular/cli`

When I run ng 
- `bash: /usr/bin/ng: No such file or directory`

Comment 6 qmxs98xl 2024-04-25 04:02:23 UTC
(In reply to qmxs98xl from comment #5)
> (In reply to Zephyr Lykos from comment #4)
> > OK, I figured this out.
> > 
> > You are running npm as root and your npmrc sets `prefix=/usr`, which
> > overrides `/usr/lib/node_modules` to a folder instead of a symlink.
> > Please don't install npm packages globally, at least not installing to
> > `/usr/lib`.
> 
> Issue is that I need to install `@angular/cli` . If I dont install it
> globally then `ng` command is not working
> 
> Things I did
> - `npm init`
> - `npm i @angular/cli`
> 
> When I run ng 
> - `bash: /usr/bin/ng: No such file or directory`

Also I have tried the same after installing fedora 40