How to debug code in boot script

64 views
Skip to first unread message

Terrence Ong

unread,
Mar 28, 2015, 12:25:51 AM3/28/15
to loopb...@googlegroups.com
I have created a custom boot script under server/boot/myBootScript.js
The script run fine, the code got executed.

However, when i debug my code using node-inspector, I cannot break in any line of the code in myBootScript.js
I break on the first line of my server.js, then put a break point in the boot script, then press continue. It just skip right through the code.

How can i debug my code in boot script??

Ritchie Martori

unread,
Mar 28, 2015, 12:40:25 AM3/28/15
to Terrence Ong, loopb...@googlegroups.com
Put the literal keyword "debugger" in your boot script and run inspector.
--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Terrence Ong

unread,
Mar 28, 2015, 12:48:02 AM3/28/15
to loopb...@googlegroups.com, ct.o...@gmail.com
I tried that. It works on other part of my code but jus not the boot script. :(

Raymond Feng

unread,
Mar 28, 2015, 1:16:09 AM3/28/15
to Terrence Ong, loopb...@googlegroups.com
How does your boot script look like? If you add a console.log(‘my boot script’), will you see the output? I can set breakpoints in my boot script and node-inspector is able to hit it.

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

Terrence Ong

unread,
Mar 28, 2015, 1:32:57 AM3/28/15
to loopb...@googlegroups.com, ct.o...@gmail.com
Nothing special, its just an ordinary one.
The project was created by the slc loopback scaffolding. I can't even debug the default boot script.
Can you show me how you load the boot script in ur server.js? i suspect it has something to do with how we load the script.

below is my code in the boot script:

module.exports = function (server) {

    console.log('Initialize:START');
    
    debugger;
    server.models.Role.create({
        name: 'RegularUser'
    }, function (err, role) {
        if (err)
            throw err;
    });

    console.log('Initialize:END');
};

Andreas Taube

unread,
Apr 2, 2015, 5:15:48 PM4/2/15
to loopb...@googlegroups.com, ct.o...@gmail.com
Have you tried switching your browser? I had the same problem and was able to start debugging after switching from Chrome to Safari. 

regards
Andreas
Reply all
Reply to author
Forward
0 new messages