Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notes for coffee-script dependency when generating init files. #1061

Closed
wants to merge 1 commit into from
Closed

Conversation

yorkxin
Copy link

@yorkxin yorkxin commented May 7, 2014

Tell user to add "coffee-script" dependency in package.json when generating a config file with ".coffee" extension.

I'm new to Node.js and Karma. When I'm generating init files with ".coffee" extension, I found that it is not possible to run karma until I add "coffee-script" dependency to package.json.

The error I got was:

/Users/chitsaou/projects/secret/spec/karma.conf.coffee:1
(function (exports, require, module, __filename, __dirname) { # Karma configur
                                                              ^
ERROR [config]: Invalid config file!
  SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.parseConfig (/Users/chitsaou/projects/secret/node_modules/karma/lib/config.js:250:22)
    at Object.exports.start (/Users/chitsaou/projects/secret/node_modules/karma/lib/server.js:273:20)
    at Object.exports.run (/Users/chitsaou/projects/secret/node_modules/karma/lib/cli.js:224:25)
    at Object.<anonymous> (/Users/chitsaou/projects/secret/node_modules/karma/bin/karma:3:23)
ERROR [config]: You need to install CoffeeScript.
  npm install coffee-script --save-dev

After adding "coffee-script" dependency I can start karma server and everything seems fine.

Tell user to add "coffee-script" dependency in package.json when generating a config file with ".coffee" extension.
@yorkxin
Copy link
Author

yorkxin commented May 7, 2014

Update

Didn't see that last line in error message until I posted this PR. But I still feel it would be better if such dependency is noted in the document.

So another question: should it be "don't forget to npm install coffee-script instead of "don't forget to add coffee-script to package.json"?

@cironunes
Copy link
Member

Maybe something like "don't forget to have coffee-script installed npm install --save-dev coffee-script"

in --save-dev is implicit that it should be on the package.json

@vojtajina
Copy link
Contributor

karma init already installs karma plugins, I think it should install coffee-script (if not already installed).

Ideally, even the error from Karma should say "You are probably missing coffee-script, do you wanna install it?"

@yorkxin
Copy link
Author

yorkxin commented May 10, 2014

I ran karma init with a file name ending with .coffee, but unfortunately it does not add coffee-script to package.json. So maybe adding it to dependency is a better solution.

@silvenon
Copy link

karma init automatically adds karma-coffee-preprocessor to package.json, which should be all that's necessary. I don't get that error... Maybe because I have it globally installed?

@vojtajina
Copy link
Contributor

@silvenon yes, I think it's because you have coffee-script installed globally.

Anybody willing to fix this? I think two things need to be done:
1/ karma init should install coffee-script (in the same way it installs Karma plugins), if the config file is *.coffee.
2/ the error should suggest that you install coffee-script (when failing to load *.conf.coffee file)

I think it's much better to fix the issue than adding a note in the docs how people should fix it themselves.

@vojtajina
Copy link
Contributor

Created issues. Closing this.

@vojtajina vojtajina closed this Aug 5, 2014
@yorkxin
Copy link
Author

yorkxin commented Aug 5, 2014

Thanks. I'll follow the new issues :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants