diff --git a/Evaluator.hs b/Evaluator.hs
--- a/Evaluator.hs
+++ b/Evaluator.hs
@@ -70,18 +70,15 @@
   where
     out = BS.concat
           [ "process.on('uncaughtException', function(err) {\n"
-          , "  var input = '", BSC.pack input, "';\n"
-          , "  var msg = (input.slice(0,7) === 'import ') ? ", badImport, " : ('Runtime error: ' + err);\n"
-          , "  process.stderr.write(msg);\n"
+          , "  process.stderr.write(err);\n"
           , "  process.exit(1);\n"
           , "});\n"
-          , "var context = { inputs:[] };\n"
+          , "var document = document || {};"
+          , "var window = window || {};"
+          , "var context = { inputs:[], addListener:function(){}, node:{} };\n"
           , "var repl = Elm.Repl.make(context);\n"
           , "if ('", Env.output, "' in repl)\n"
           , "  console.log(context.Native.Show.values.show(repl.", Env.output, "));" ]
-
-    badImport = "('Error: unable to import \\\"' + input.slice(7).replace(/ /g,'') + '\\\".\\nIt may rely on a browser API that is unavailable on the command line.')"
-
 
 scrapeOutputType :: BS.ByteString -> BS.ByteString
 scrapeOutputType types
diff --git a/Repl.hs b/Repl.hs
--- a/Repl.hs
+++ b/Repl.hs
@@ -1,16 +1,24 @@
 {-# LANGUAGE OverloadedStrings #-}
 module Main where
 
+import Control.Monad
 import Control.Monad.Trans
 import System.Console.Haskeline
 import qualified Evaluator as Eval
 import qualified Environment as Env
+import System.Directory
 import System.Exit
 
 main :: IO ()
-main = runInputT defaultSettings $ withInterrupt $ loop Env.empty
+main = do
+  buildExisted <- doesDirectoryExist "build"
+  cacheExisted <- doesDirectoryExist "cache"
+  exitCode <- runInputT defaultSettings $ withInterrupt $ loop Env.empty
+  when (not buildExisted) (removeDirectoryRecursive "build")
+  when (not cacheExisted) (removeDirectoryRecursive "cache")
+  exitWith exitCode
 
-loop :: Env.Repl -> InputT IO ()
+loop :: Env.Repl -> InputT IO ExitCode
 loop environment@(Env.Repl _ _ _ wasCtrlC) = do
   str' <- handleInterrupt (return Nothing) getInput
   case str' of
@@ -18,7 +26,7 @@
         loop =<< liftIO (Eval.runRepl input $ environment {Env.ctrlc = False})
 
     Nothing
-        | wasCtrlC  -> lift $ exitWith (ExitFailure 130)
+        | wasCtrlC  -> return (ExitFailure 130)
         | otherwise -> do 
               lift $ putStrLn "(Ctrl-C again to exit)"
               loop $ environment {Env.ctrlc = True}
diff --git a/elm-repl.cabal b/elm-repl.cabal
--- a/elm-repl.cabal
+++ b/elm-repl.cabal
@@ -1,5 +1,5 @@
 Name:                elm-repl
-Version:             0.1.0.1
+Version:             0.1.0.2
 Synopsis:            a REPL for Elm
 Description:         A read-eval-print-loop (REPL) for evaluating Elm expressions,
                      definitions, ADTs, and module imports. This tool is meant to
