Atom is not defined


TL;DR My question is: how do i access the atom instance in scripts outside

i am completely new to atom, and fiddling with coffeescript in the init package. To avoid testing my partial scripts by exiting+re-entering all the time, i added the “script” package and try to run my file. However, it seems that script can’t access the atom classes i.e. i get the error

ReferenceError: atom is not defined

on the 1-line script:

I tried to change working directory in the “script” package options to the directory with the atom exe and the but without succes.

Apologies if this is not the appropriate forum to ask this question


Did you require/import atom?


I think so. As mentioned i am a beginner, but i tried to put either of these on top without change:
{Atom} = require ‘atom’
{atom} = require ‘atom’


What script does is execute a command-line instruction to a binary that can parse the code. I know of no way to import Atom’s globals from an external script.

What you can do is to use a package like preview to look at what your CoffeeScript will look like as JavaScript, and then use the developer tools console (View -> Developer -> Toggle developer tools and select the Console tab) to run the code (just paste it in, and if it’s valid it will run).


OK Thanks for answer!