Proper undefined checks

To prevent possible errors for `console` and `module`, I added a "proper" undefined check to both console and module.

I also changed from `console.error` to `console.warn`, as it makes more sense to warn about elements that doesn't exist instead of throwing an error in the console.