Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'match' of undefined #25

Closed
eassymo opened this issue Feb 21, 2018 · 3 comments
Closed

Cannot read property 'match' of undefined #25

eassymo opened this issue Feb 21, 2018 · 3 comments

Comments

@eassymo
Copy link

eassymo commented Feb 21, 2018

Uncaught Error: Cannot read property 'match' of undefined: Error during instantiation of AgendaService! (Server -> AgendaService).

wrappedError
injectionError
instantiationError
ReflectiveInjector_._instantiate

Enviroment:
injection-js: ~2.2.1
npm: 5.5.1
node: 9.2.0
typescript: ~2.5.3

@eassymo
Copy link
Author

eassymo commented Feb 21, 2018

import 'reflect-metadata';
import {Injectable, ReflectiveInjector} from "injection-js";
import {AgendaService} from "./app/service/agenda.service";

@Injectable()
class Server {
    constructor(private agendaService: AgendaService) {
    }
}

const injector = ReflectiveInjector.resolveAndCreate([
    AgendaService
]);

const server: Server = injector.get(Server);

@eassymo
Copy link
Author

eassymo commented Feb 21, 2018

// etc
@Injectable()
export class AgendaService {
constructor(){
        this._agenda = new Agenda();
        // edit: the ausent SOME_VAR causes the error
        this._agenda.database(process.env.SOME_VAR);
}
//etc

@eassymo
Copy link
Author

eassymo commented Feb 21, 2018

it's caused by an ausent enviroment variable

process.env.SOME_VAR

if it does not exists throws this error:

Cannot read property 'match' of undefined

Adding enviroment var, fixes the problem.

issue updated.

@eassymo eassymo closed this as completed Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant