Unable to use console.log


I can’t seem to get console.log to work in my package. I am convinced I have my package.json file setup correctly and that Atom sees my package because this code works:

module.exports =
  activate: ->
    editor = atom.workspace.getActiveEditor()
    atom.workspaceView.command "plugin:run", =>
      editor.insertText "Activated"

But trying to log to console doesn’t work (suggested here):

module.exports =
  activate: ->
    console.log "Activated"

Does anyone have ideas on getting this to work?


Autostart packages
How to make my package auto activate
Having `activationEvents` is confusing

Any errors in the console? Usually console.log should work perfectly.



There are no errors in the console, no.



Do you have an activationEvents key in your package’s package.json file? If so, the package won’t be loaded until that event is triggered.



I had the same problem today and this was the culprit.



I don’t have an activationEvents key and still can’t get things to show up in console.

A Gist with some code, if anyone’s curious: https://gist.github.com/bleikamp/b16e44a0802773553445



Yes, you need an activationEvents key so Atom knows when to activate your package. Otherwise, it won’t ever be activated and no code of yours will ever run. For example:

1 Like


It doesn’t work either way. I added this to line 7 of my package.json file:

"activationEvents": ["atom-plugin:run"],


If you don’t add activationEvents the package will still run, but if every package did this Atom’s startup time would become slow.

Here are some other things to check.

  1. Make sure main in your package.json file points to the correct place. It uses relative paths so it should look something like “./lib/my-super-cool-package”

  2. Put console.log('HI BEN!') at the top of your main file to check that it is actually being loaded.

  3. Open up the dev tools console cmd-alt-i and type atom.packages.loadedPackages make sure your package is in that list.

If everything there seems cool, then let me know and we can dig deeper.

1 Like

[SOLVED] Auto triggering package

Turns out there is not a bug or a problem, I just accidentally selected the Errors tab in my console. How embarrassing.

A screenshot for those trying to debug similar problems: https://dl.dropboxusercontent.com/s/aap1qj6z5g25ssw/2014-03-06%20at%204.10%20PM%202x.png



I hit this same issue, I didn’t have “main” defined in my package.json file, b/c it wasn’t generated by the $ apm --convert command. Cost me a lot of time, but this comment is what ultimately helped me find the issue. Thank you, Corey (probably).



I also cannot get any console.log to work. The package is running, it is activated but no console.log is posting.

Additionally if I open up the console and just enter console.log(‘hello’) it doesn’t even log.

Ah, found it. linter-python is completely disabling console.log