Error

node:internal/modules/cjs/loader:1148 throw err; ^ Error: Cannot find module './lib/arrayStrictEquals.mjs'
43 Replies
UndiedGFX
UndiedGFX7mo ago
there is no file called './lib/arrayStrictEquals.mjs'
Baylem
Baylem7mo ago
This may have something to do with the recent Shapeshift or Utilities update as I started getting this error as well after updating some versions in my package.json
UndiedGFX
UndiedGFX7mo ago
we might need the full error stack upon this one tho as you're on it, mind sending the full stack and file contents of node_modules/@sapphire/shapeshift?
Baylem
Baylem7mo ago
> discord-rewrite@1.0.0 start
> node dist/index.js

node:internal/modules/cjs/loader:1147
throw err;
^

Error: Cannot find module './lib/arrayStrictEquals.mjs'

Error: Cannot find module './lib/arrayStrictEquals.mjs'
Require stack:
- C:\Users\Dev\WebstormProjects\discord-rewrite\node_modules\@sapphire\utilities\dist\cjs\index.cjs
- C:\Users\Dev\WebstormProjects\discord-rewrite\dist\lib\util\times.js
- C:\Users\Dev\WebstormProjects\discord-rewrite\dist\lib\constants.js
- C:\Users\Dev\WebstormProjects\discord-rewrite\dist\lib\extensions\CustomClient.js
- C:\Users\Dev\WebstormProjects\discord-rewrite\dist\index.js
> discord-rewrite@1.0.0 start
> node dist/index.js

node:internal/modules/cjs/loader:1147
throw err;
^

Error: Cannot find module './lib/arrayStrictEquals.mjs'

Error: Cannot find module './lib/arrayStrictEquals.mjs'
Require stack:
- C:\Users\Dev\WebstormProjects\discord-rewrite\node_modules\@sapphire\utilities\dist\cjs\index.cjs
- C:\Users\Dev\WebstormProjects\discord-rewrite\dist\lib\util\times.js
- C:\Users\Dev\WebstormProjects\discord-rewrite\dist\lib\constants.js
- C:\Users\Dev\WebstormProjects\discord-rewrite\dist\lib\extensions\CustomClient.js
- C:\Users\Dev\WebstormProjects\discord-rewrite\dist\index.js
UndiedGFX
UndiedGFX7mo ago
PS: this could be because djs haven't updated to latest shapeshift
Baylem
Baylem7mo ago
that was my stack
UndiedGFX
UndiedGFX7mo ago
i think its not shapeshift its utilities
Baylem
Baylem7mo ago
Yeah
UndiedGFX
UndiedGFX7mo ago
@Baylem can you cat this file for me? C:\Users\Dev\WebstormProjects\discord-rewrite\node_modules@sapphire\utilities\dist\cjs\index.cjs
Baylem
Baylem7mo ago
In webstorm its just at the very top on dist/cjs/index.cjs
'use strict';

var arrayStrictEquals_mjs = require('./lib/arrayStrictEquals.mjs');
var cast_mjs = require('./lib/cast.mjs');
var chunk_mjs = require('./lib/chunk.mjs');
var classExtends_mjs = require('./lib/classExtends.mjs');
'use strict';

var arrayStrictEquals_mjs = require('./lib/arrayStrictEquals.mjs');
var cast_mjs = require('./lib/cast.mjs');
var chunk_mjs = require('./lib/chunk.mjs');
var classExtends_mjs = require('./lib/classExtends.mjs');
when I click the reference
UndiedGFX
UndiedGFX7mo ago
does node_modules@sapphire\utilities\dist\cjs\lib\arrayStrictEquals.mjs exist?
Baylem
Baylem7mo ago
just this
UndiedGFX
UndiedGFX7mo ago
iirc @Favna you broke shit, even the ci was failing in the lastest push there is a temporary workaround, change all the .mjs in imports to .cjs looking at the files in 3.15.2 all the imports are .cjs but its not in 3.16
Baylem
Baylem7mo ago
Find and Replace All my savior :prayge: nah its all broken i fix one file another pops up fix that one another pops up this one is
UndiedGFX
UndiedGFX7mo ago
@eX you have to open node_modules@sapphire\utilities\dist\cjs\index.cjs then replace all .mjs with .cjs until they fix it
Baylem
Baylem7mo ago
dist\cjs\lib\cutText
'use strict';

var splitText_mjs = require('./splitText.mjs');
'use strict';

var splitText_mjs = require('./splitText.mjs');
UndiedGFX
UndiedGFX7mo ago
i'm trying to see where this bug landed
Baylem
Baylem7mo ago
dist\cjs\lib\deepClone.mjs
'use strict';

var isPrimitive_mjs = require('./isPrimitive.mjs');
'use strict';

var isPrimitive_mjs = require('./isPrimitive.mjs');
yeah it just keeps going
UndiedGFX
UndiedGFX7mo ago
@Baylem i believe there was a flag that would interop cjs and mjs in nodejs right? try using that?
Baylem
Baylem7mo ago
dist\cjs\index.cjs dist\cjs\lib\cutText dist\cjs\lib\deepClone dist\cjs\lib\filterNullAndUndefined dist\cjs\lib\filterNullAndUndefinedAndEmpty ... list goes on yeah I'm gonna use that instead of doing this, idk how many there will be
UndiedGFX
UndiedGFX7mo ago
what was the flag?
Baylem
Baylem7mo ago
I think its --experimental-modules i havent tried yet
UndiedGFX
UndiedGFX7mo ago
try and tell me if your bot runs now
Baylem
Baylem7mo ago
Yeah no that flag doesn't work becuase you have to change type: module and that breaks everything else
UndiedGFX
UndiedGFX7mo ago
@Baylem i think its --experimental-require-module
Baylem
Baylem7mo ago
oh right
UndiedGFX
UndiedGFX7mo ago
no s lmk if that works
Baylem
Baylem7mo ago
nah --experimental-modules does run but runs into the same mjs import error --experimental-require-module doesn't exist
UndiedGFX
UndiedGFX7mo ago
If --experimental-require-module is enabled, and the ECMAScript module being loaded by require() meets the following requirements:

The module is fully synchronous (contains no top-level await); and
One of these conditions are met:
The file has a .mjs extension.
The file has a .js extension, and the closest package.json contains "type": "module"
The file has a .js extension, the closest package.json does not contain "type": "commonjs", and --experimental-detect-module is enabled.
If --experimental-require-module is enabled, and the ECMAScript module being loaded by require() meets the following requirements:

The module is fully synchronous (contains no top-level await); and
One of these conditions are met:
The file has a .mjs extension.
The file has a .js extension, and the closest package.json contains "type": "module"
The file has a .js extension, the closest package.json does not contain "type": "commonjs", and --experimental-detect-module is enabled.
weird node 22?
Baylem
Baylem7mo ago
I'm running v20 , so that might be a 22 thing I was running LTS I'll update node
UndiedGFX
UndiedGFX7mo ago
that flag was released like 2 months ago
Baylem
Baylem7mo ago
ah ok makes sense this project is on an older node version Dumb question but for a production level project, should I go ahead and update to 22? I was only staying on 20 for LTS
UndiedGFX
UndiedGFX7mo ago
if you want to update to 22 only to use the flag, better not favna broke something in his esbuild plugin
Baylem
Baylem7mo ago
Yeah I'll just wait on Favna p sure favna will see this, but should I go ahead and open a github issue? @UndiedGFX
UndiedGFX
UndiedGFX7mo ago
might not be necessary
Favna
Favna7mo ago
Dafuq happened :dragonwhat: For now set your resolutions to utilities 3.15.x I guess
Spinel
Spinel7mo ago
npm npm doesn't have anything to update transient dependencies so you'll have to provide overrides. In your package.json:
{
"overrides": {
"package-name-here": "version"
}
}
{
"overrides": {
"package-name-here": "version"
}
}
Then run npm install. You can verify the change by checking your package-lock.json Yarn v1 Yarn v1 (deprecated, recommend updating to v4 (see /tag query:yarnv4 ) does not have a way to update transient dependencies so a similar strategy is required as npm: In your package.json:
{
"resolutions": {
"package-name-here": "version"
}
}
{
"resolutions": {
"package-name-here": "version"
}
}
Then run yarn install. You can verify the change by checking your yarn.lock Yarn v4 Yarn v4 can update transient dependencies so run the command:
yarn up -R package-name-here
yarn up -R package-name-here
pnpm pnpm can also update transient dependencies so run the command:
pnpm --recursive update package-name-here@version
pnpm --recursive update package-name-here@version
Favna
Favna7mo ago
Ignore the whole update thing there
UndiedGFX
UndiedGFX7mo ago
@eX @Baylem issue solved in 3.16.1
Baylem
Baylem7mo ago
Thanks
eX
eXOP7mo ago
@UndiedGFX@Baylem 3.16.1 sapphire ?
UndiedGFX
UndiedGFX7mo ago
@sapphire/utilities
eX
eXOP7mo ago
Damn it! Its work
Want results from more Discord servers?
Add your server