`browser/init.coffee` looks for JS file, but not coffeescript


Hey all!

I started with atom-shell-starter and now I’m trying to package my app. I have my app.asar file in /Contents/Resources/app.asar, and when I run my app, it seems to locate and launch the asar. But when atom/browser/init.coffee loads my main file (I think here), it only tries to find the .js file but not the .coffee file.

Cannot find module 'Users/hank/node/my-app/atom-shell/MyApp.app/Contents/Resources/app.asar/src/browser/main.js`

Could it be that the .coffee exension hasn’t been rendered? Do I need to compile js files when packaging?

Thanks for your help! Using atom-shell has been amazing so far.


If you want to require 'XXX.coffee' you should first require coffee-script/register. It basically patches node’s require function to also recognize .coffee files:

// you can now require files with the .coffee extension


By the way, anyone should take a look at the coffee-script/register script, it’s really easy to modify to make custom requires. For example: require '../templates/some-template.jade' and have it automatically transform a jade template into a javascript function


The first error was that the main property in the package.json of atom-shell-starter is src/browser/main.js, even though the main file is main.coffee. This re-affirms my confusion about possible having to compile js files when packaging. Nonetheless, I changed it to main.coffee and that fixed the first error of Module not found.

Then I repacked my asar and re-ran the packaged app from atom-shell, and I got the classic coffeescript error:

exports, require, module, __filename, __dirname) { blah = require 'blah'

SyntaxError: Unexpected string

This definitely meant there was a require('coffee-script/register') missing somewhere. I started digging in atom-shell and added require('coffee-script/register') to browser/init.coffee and then built atom-shell from source.

I added my app.asar to the built Atom.app and ran the app. Now when I open Atom.app the app launches, but nothing happens. No windows open. This doesn’t happen when I run my app with script/run. When I remove the require('coffee-script/register') line, build, and run, I get the same SyntaxError: Unexpected string error.

Anyone have an idea why nothing happens when I run the built app with my app.asar?



I have no idea what that app.asar is… I just remember from my messing around with atom-shell (half a year ago, mind you), I just had "main": "main.js" in package.json and this in main.js:


and from that point I could just require 'XXX.coffee' (I had to do this in the browser and the renderer though)