You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ts-node throws config:ts-node TypeError: module_1.Module._preloadModules is not a function.
With a workaround for the issue above oclif throws this warning warn: Requested module is not instantiated yet
To Reproduce
Steps to reproduce the behavior:
Create a new oclif project bunx oclif generate pe1ucaCLI
In bin/dev replace the first line with #!/usr/bin/env bun
In the same file comment require('ts-node').register({project})
Run bin/dev hello:world
See oclif doesn't find the example command
Expected behavior
oclif should run the commands from the source code.
Screenshots
Environment (please complete the following information):
OS & version: Ubuntu 22.04.3 LTS
Shell/terminal & version bash-5.1.16
Additional context
require('ts-node').register({project}) throws an error due to an issue with bun oven-sh/bun#6227
Since bun has typescript as first-class citizen this dependency is not necessary.
But commenting this line is not enough, since oclif/core has another call to register
Commenting both of these lines makes oclif properly load the source code.
Before commenting the line in core
config loading core plugin from /home/pe1uca/Documents/pe1ucaCLI +0ms
config:ts-node registering ts-node at /home/pe1uca/Documents/pe1ucaCLI +0ms
config:ts-node ts-node path: /home/pe1uca/Documents/pe1ucaCLI/node_modules/ts-node/dist/index.js +0ms
config:ts-node TypeError: module_1.Module._preloadModules is not a function. (In 'module_1.Module._preloadModules(service.options.require)', 'module_1.Module._preloadModules' is undefined)
config:ts-node at register (/home/pe1uca/Documents/pe1ucaCLI/node_modules/ts-node/src/index.ts:4:37)
config:ts-node at /home/pe1uca/Documents/pe1ucaCLI/node_modules/@oclif/core/lib/config/ts-node.js:58:13
config:ts-node at processTicksAndRejections (:13:78) +28ms
config:pe1ucaCLI loading IDs from /home/pe1uca/Documents/pe1ucaCLI/dist/commands +0ms
config:pe1ucaCLI found commands [] +11ms
After commenting it
config:ts-node registering ts-node at /home/pe1uca/Documents/pe1ucaCLI +0ms
config:ts-node ts-node path: /home/pe1uca/Documents/pe1ucaCLI/node_modules/ts-node/dist/index.js +0ms
config:ts-node tsconfig: {
config:ts-node <tsconfig>
config:ts-node } +14ms
config:ts-node ts-node options: {
config:ts-node <ts-node options>
config:ts-node } +1ms
config:ts-node determining path for /home/pe1uca/Documents/pe1ucaCLI/dist/commands +0ms
config:ts-node lib dir: /home/pe1uca/Documents/pe1ucaCLI/dist +0ms
config:ts-node src dir: /home/pe1uca/Documents/pe1ucaCLI/src +0ms
config:ts-node src commands dir: /home/pe1uca/Documents/pe1ucaCLI/src/commands +0ms
config:ts-node Found source file for /home/pe1uca/Documents/pe1ucaCLI/dist/commands at /home/pe1uca/Documents/pe1ucaCLI/src/commands +0ms
config:pe1ucaCLI loading IDs from /home/pe1uca/Documents/pe1ucaCLI/src/commands +0ms
config:pe1ucaCLI found commands [
<list of all commands in src>
] +12ms
With the fix above the warning warn: Requested module is not instantiated yet shows up, can't see something in my project affected by this, the commands run properly.
Seems related to this part of the code
constisPlugin=(config: IConfig|IPlugin): config is IPlugin=>(<IPlugin>config).type!==undefined
Here's the log
warn: Requested module is not instantiated yet.
at link (:1:11)
at linkAndEvaluateModule (:1:11)
at <anonymous> (/home/pe1uca/Documents/pe1ucaCLI/node_modules/@oclif/core/lib/module-loader.js:16:93)
at processTicksAndRejections (:12:39)
module: @oclif/core@3.18.2
task: cacheCommand
plugin: pe1ucaCLI
root: /home/pe1uca/Documents/pe1ucaCLI
See more details with DEBUG=*
warn: Requested module is not instantiated yet.
at link (:1:11)
at linkAndEvaluateModule (:1:11)
at <anonymous> (/home/pe1uca/Documents/pe1ucaCLI/node_modules/@oclif/core/lib/module-loader.js:16:93)
at processTicksAndRejections (:12:39)
module: @oclif/core@3.18.2
task: cacheCommand
plugin: pe1ucaCLI
root: /home/pe1uca/Documents/pe1ucaCLI
See more details with DEBUG=*
The text was updated successfully, but these errors were encountered:
Seems the issue with the requested module cause by trying to load a command with an import with a relative path. import * as config from '../../config';
Describe the bug
config:ts-node TypeError: module_1.Module._preloadModules is not a function
.warn: Requested module is not instantiated yet
To Reproduce
Steps to reproduce the behavior:
bunx oclif generate pe1ucaCLI
bin/dev
replace the first line with#!/usr/bin/env bun
require('ts-node').register({project})
bin/dev hello:world
Expected behavior
oclif should run the commands from the source code.
Screenshots
Environment (please complete the following information):
Additional context
require('ts-node').register({project})
throws an error due to an issue with bun oven-sh/bun#6227Since bun has typescript as first-class citizen this dependency is not necessary.
But commenting this line is not enough, since oclif/core has another call to register
core/src/config/ts-node.ts
Line 94 in 49a4841
Commenting both of these lines makes oclif properly load the source code.
Before commenting the line in core
After commenting it
With the fix above the warning
warn: Requested module is not instantiated yet
shows up, can't see something in my project affected by this, the commands run properly.Seems related to this part of the code
core/src/module-loader.ts
Line 19 in 49a4841
Here's the log
The text was updated successfully, but these errors were encountered: