Recent releases of Greasemonkey seem to adequately report line numbers, but it is best to debug and test as much of your script as possible in the Firebug console before using it in a Greasemonkey script.
And, as has not been said, jsHint can be useful for detecting these problems.
Anyway, suppose I have a script:
// ==UserScript==
// @name _Debugging test
// @include http://YOUR_SERVER/YOUR_PATH/*
// ==/UserScript==
unsafeWindow.console.log ('Line 1', 1 + 0);
unsafeWindow.console.log ('Line 2', 1 + 1);
unsafeWindow.console.log ('Line 3', 1 + 2);
unsafeWindow.console.log ('Line 4 **Throw error here**', 1 + 3 + nonExistantVariable);
unsafeWindow.console.log ('Line 5', 1 + 4);
When I run it on 2 of my systems (WinXP, FF: 10.0.2, GM: 0.9.18, Firebug: 1.9.1 and the same except GM: 0.9.17), I get this on the Firebug console:
Line 1 1
Line 2 2
Line 3 3
and this is on the Firefox console Error ( Ctrl Shift J):

Clicking on the link gives:

There is no true debugging feature, it is not much better.
source
share