Closed alberto-leon-crespo closed 6 years ago
hi @alberto-leon-crespo ! I think typescript is not supported at the moment! DI tries to load javascripts files and not ts. Can you try to rename your filename to .js
instead of .ts
Hi @zazoomauro ! I rename filename to '.js' but i get the same error. I try to debug program but i cant dump the informatión of path in load process. I tried with console.log, utils.debug and something similar but i cant.
¿how i can debug module to add this funcionality?
@alberto-leon-crespo may be can be a filename error issues. Can you try to remove the dots in the filename? like: instead of dummy.service.js
to dummyService.js
if success there is bug with dots in the filename
@zazoomauro removing dot in the filename i get the same error. I try to debug module
@alberto-leon-crespo let me know
@zazoomauro I debug source to know the problem. When use require
in Loader class, path is relative to loader directory in node_modules
. I resolve problem with class path with a path like this ../../../../../dist/services/dummyservice
. But i think this is not a real solution for this problem. I try to change "node_path" with a package directive moduleSearchPaths
but i cant resolve the problem with this. I dont know how to fix that problem.
@zazoomauro I solve the problem with the next fix in the file Loader.js in method _requireClassNameFromPath
.
return require(process.cwd() + "/" + path.join(fromDirectory, classObject)).default;
Can u fix that?
@alberto-leon-crespo I stil not convinced. process.cwd()
contains exactly the same value of fromDirectory
Can you please show me the output of your fromDirectory
parameter?
Can you please show me the output of your this.filePath
parameter?
@zazoomauro I think load of classes has been relative to project directory, but is only a opinion. Here values of fromDirectory
and this.filePath
:
fromDirectory: app/config this.filePath: app/config/services.yaml
@alberto-leon-crespo I know what is going on. Can u please send the ABSOLUTE path during your configuration file loader? So instead of this
loader.load('app/config/services.yaml');
use something like this:
loader.load(path.join(__dirname, 'app/config/services.yaml'));
Then we can discuss if only enabling absolute path during loading is good or bad.
We can enable a flag to enable relative file path loading... etc..
An easy fix could be check if the file path is absolute or relative and do the magic
depending on this. What do you think @alberto-leon-crespo ?
I think is good idea. I try to load config file with loader.load(path.join(__dirname, 'app/config/services.yaml'));
. BTW i can fix the problem until you publish enchancement.
@alberto-leon-crespo should be ready for the 2.1 version.
I don´t think this can be done... after further investigation, we are just sending a string value as a function parameter. No way to join the whole path to make it absolute. No way to ask the user to provide __dirname
value
I can fix the problem using absolute path to load config file.
loader.load(process.cwd() + '/' + this.fixRoute + '/config/services.yaml');
Hi i became a implementation in my own framework based on express. This is the folder structure:
I load config file in my app.ts file with this function:
This is my services.yaml file:
This is my dummy.service file:
But when i try to load application i get this error:
Do u have any idea of what is wrong?