olov / ng-annotate

Add, remove and rebuild AngularJS dependency injection annotations
MIT License
2.03k stars 150 forks source link

Can't reuse your ng-annotate-main.js in node v0.12 without --harmony flag #173

Closed qiu8310 closed 9 years ago

qiu8310 commented 9 years ago

I write some cli program, and want use your ngAnnotate, like this:

var ngAnnotate = require('ng-annotate/ng-annotate-main');
// ...
console.log(ngAnnotate(someContent, {add: true, 'single_quotes': true}).src);

It always get the errors:

/Users/Mora/Workspace/node/test/node_modules/ng-annotate/ng-annotate-main.js:6
const fmt = require("simple-fmt");
^^^^^
SyntaxError: Use of const in strict mode.

On the other hand, can't figure out how to inject the --harmony flag to the cli program.

qiu8310 commented 9 years ago

Sorry, should use your build version.

olov commented 9 years ago

Correct. If you installed ng-annotate using npm then a simple var ngAnnotate = require("ng-annotate") will work from your es5 application. If you've cloned the repo then you need to run the build-script first.