Cannot register a type name as a singleton without a "to" token
EnochOluwadamilare opened this issue · 1 comments
Hello,
I get the error:
Error: Cannot register a type name as a singleton without a "to" token at InternalDependencyContainer.registerSingleton (C:\Users\Dimeji\Documents\UderSalon\UderSalonNew\New folder\gobarber\backend\node_modules\tsyringe\dist\cjs\dependency-container.js:83:19) at Object.<anonymous> (C:\Users\Dimeji\Documents\UderSalon\UderSalonNew\New folder\gobarber\backend\src\shared\container\providers\StorageProvider\index.ts:13:11) at Module._compile (internal/modules/cjs/loader.js:778:30) at Module._compile (C:\Users\Dimeji\Documents\UderSalon\UderSalonNew\New folder\gobarber\backend\node_modules\source-map-support\source-map-support.js:547:25) at Module.m._compile (C:\Users\Dimeji\AppData\Local\Temp\ts-node-dev-hook-25451513852310415.js:57:25) at Module._extensions..js (internal/modules/cjs/loader.js:789:10) at require.extensions.(anonymous function) (C:\Users\Dimeji\AppData\Local\Temp\ts-node-dev-hook-25451513852310415.js:59:14) at Object.nodeDevHook [as .ts] (C:\Users\Dimeji\Documents\UderSalon\UderSalonNew\New folder\gobarber\backend\node_modules\ts-node-dev\lib\hook.js:61:7) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) [ERROR] 17:40:47 Error: Cannot register a type name as a singleton without a "to" token
I have done everything to set up my .env file shown below:
`
Application
APP_SECRET=
APP_API_URL=http://localhost:3333
APP_WEB_URL=http://localhost:3000
MAIL_DRIVER=ethereal
AWS Credentials
AWS_ACCESS_KEY_ID=AKIA4XXXXXXXWWCBXXQ
AWS_SECRET_ACCESS_KEY=1kXqtkzXXXXXXXXXXg6fGq/2Y5o4HLQ
AWS_DEFAULT_REGION=us-west-2
#Storage
STORAGE_DRIVER=vfs
#Redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASS=""
TYPE=postgres
DB_DIALECT=postgres
DB_TYPE=postgres
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASS=EnXXXXre1.
DB_NAME=gobarber
NODE_ENV=development
STORAGE_TYPE=local
Auth
APP_SECRET=gobarbertests
MAIL_HOST=
MAIL_PORT=
MAIL_USER=
MAIL_PASS=
Sentry
SENTRY_DSN=
APP_URL_S3=s3://localhostman/
BUCKET=s3://localhostman/
`
And configured the ormconfig.json file too:
[ { "name": "default", "type": "postgres", "host": "localhost", "post": 5432, "username": "postgres", "password": "EnXXXXre1.", "database": "gobarber", "entities": [ "./src/modules//infra/typeorm/entities/.ts" ], "migrations": [ "./src/shared/infra/typeorm/migrations/.ts" ], "cli": { "migrationsDir": "./src/shared/infra/typeorm/migrations" } }, { "name": "mongo", "type": "mongodb", "host": "localhost", "port": 27017, "database": "myLegendaryDatabase", "useUnifiedTopology": true, "entities": [ "./src/modules//infra/typeorm/schemas/*.ts" ] } ]
However I still get the error...
Environment:
- Windows
- postres DB (without docker- I have little knowledge of Docker)
- Please can you help? OR assist with a BASE_URL for testing OR assist with deploying to Heroku/AWS
Hello @EnochOluwadamilare ,
If you look here https://github.com/StefanoSaffran/gobarber/blob/master/backend/src/shared/container/providers/StorageProvider/index.ts#L15
We passed the StorageProvider that we defined here
https://github.com/StefanoSaffran/gobarber/blob/master/backend/src/config/upload.ts#L28
So pay attention if you actually have this vft
that you used in the env file STORAGE_DRIVER = vfs
Maybe that's the problem.
Because the interface, if you haven't changed the definition, is prepared to receive only 's3' | 'disk'
.