我如何用咖啡脚本和ES6创build一个sails.js项目

我尝试使用咖啡脚本和ES6创buildsails.js项目首先,我使用新的'appName'和npm install咖啡脚本–save npm install babel –save

并修改app.js

options = { loose : "all", stage : 1, ignore : null, only : null, extensions: null }; require("sails-hook-babel/node_modules/babel/register")(options); 

但是这是错的

我看到别人可以通过自动创build它(它可以创buildapp.coffee local.coffee …等不需要修改)如何做到这一点?

 ----------------------------------------------- error: ** Grunt :: An error occurred. ** error: ------------------------------------------------------------------------ Warning: Task "watch" not found. Aborted due to warnings. ------------------------------------------------------------------------ error: Looks like a Grunt error occurred-- error: Please fix it, then **restart Sails** to continue running tasks (eg watching for changes in assets) error: Or if you're stuck, check out the troubleshooting tips below. error: Troubleshooting tips: error: error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure. error: error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc. error: error: *-> Or maybe you don't have permissions to access the `.tmp` directory? error: eg, `/Users/yangjunzhang/Documents/workspace/burstWork/.tmp` ? error: error: If you think this might be the case, try running: error: sudo chown -R 501 /Users/yangjunzhang/Documents/workspace/burstWork/.tmp 

最好使用babel包作为独立包,而不是sails-hook-babel 。 我的整合stream程如下所示:

1)安装babel-clibabel-preset-es2015

 npm install --save babel-cli babel-preset-es2015 

2)用下面的脚本改变你的package.json文件, scripts部分:

 "scripts": { "start": "babel-node --presets es2015 app.js" } 

3)用npm start脚本启动你的应用程序:

 npm start 

之后,您可以使用ES6语法编写所有代码,并使用npm start来启动项目。