Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用coffee脚本和ES6创建sails.js项目_Javascript_Node.js_Coffeescript_Sails.js_Ecmascript 6 - Fatal编程技术网

Javascript 如何使用coffee脚本和ES6创建sails.js项目

Javascript 如何使用coffee脚本和ES6创建sails.js项目,javascript,node.js,coffeescript,sails.js,ecmascript-6,Javascript,Node.js,Coffeescript,Sails.js,Ecmascript 6,我尝试使用coffee脚本和ES6创建sails.js项目 首先,我使用sails新的“appName” 及 npm安装咖啡脚本--保存 npm安装babel--保存 并修改app.js options = { loose : "all", stage : 1, ignore : null, only : null, extensions: null }; require("sails-hook-babel/node_modules/babel

我尝试使用coffee脚本和ES6创建sails.js项目 首先,我使用sails新的“appName” 及 npm安装咖啡脚本--保存 npm安装babel--保存

并修改app.js

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

我看到其他人可以自动创建它(它可以创建app.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 (e.g. 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:      e.g., `/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
使用。我的集成流程如下所示:

1) 安装
babel cli
babel-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
启动项目