Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to access variable in google chrome console

I am using the latest version of Meteor js. I am a newbie and couldn't find the solution. I have surfed for this problem a lot.

Before going to the problem, please have look at the directory structure first.

My directory structure of the project is like this :

\client
    \main.html
    \main.css
    \main.js
\imports
    \lib
       \todos
           \todos.js
\server
    \main.js

I have created a Mongo Object in todos.js.

export const Todos = new Mongo.Collections('todos');

This is working fine.

Now in client\main.js, I am importing this object,

import { Todos } from '\imports\lib\todos\todos.js';

Note: I tried relative and absolute both type of addressing.

I put a debugger after that and checked and the variable is there. I can access that variable on the console. But as soon as I pass the statement and all the code is rendered on the browser(google chrome), I am not able to use Todos. It is giving me a ReferenceError. The error is

Todos is not defined.

I know there is no problem till the browser is loading because I checked that. I have surfed a lot. Please help me.

Thank you in advance.

Edit 1: I am using windows 7 if that is necessary.

like image 457
Chandan Purbia Avatar asked Oct 15 '25 22:10

Chandan Purbia


1 Answers

As the comments above said, variables declared or imported in a file/module don't end up on the developers console.

What you can do to get stuff on the console is import it to the console using require

> require('/imports/lib/todos/todos.js')

Any valid absolute path or package will work here

Note: the path separators are always *nix style /

like image 162
coagmano Avatar answered Oct 18 '25 12:10

coagmano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!