2013-07-19 3 views
5

로컬 개발을 위해 grunt-express를 사용하고 있습니다. 여기 grunt-express에 --harmony node 플래그를 추가하는 방법

을 시작 내가

툴툴 거리는 소리와 함께 내 로컬 서버를 시작 내 GruntFile.js

var path = require('path'); 

module.exports = function(grunt){ 
    grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json'), 
    uglify:{ 
     options:{ 
     banner:'/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' 
     } 
    }, 
    express:{ 
     server:{ 
     options:{ 
      debug:true, 
      server: path.resolve('app.js') 
     } 
     } 
    }, 
    env : { 
     options:{ 

     }, 
     dev : { 
      NODE_ENV : 'development' 
     }, 
     prod : { 
      NODE_ENV : 'production' 
     } 
    }, 
    mochaTest:{ 
     test:{ 
      options:{ 
       reporter:'spec' 
      }, 
      src:['tests/*.js'] 
     } 
    } 

    }); 

    grunt.loadNpmTasks('grunt-contrib-uglify'); 
    grunt.loadNpmTasks('grunt-express'); 
    grunt.loadNpmTasks('grunt-env'); 
    grunt.loadNpmTasks('grunt-mocha-test'); 
    grunt.loadNpmTasks('grunt-shell'); 


    // tasks 
    grunt.registerTask('start', ['env:dev', 'express', 'express-keepalive']); 
    grunt.registerTask('stop', ['express-stop']); 
    grunt.registerTask('test', 'mochaTest'); 


}; 

하지만 나는 실행 노드에 --harmony 플래그를 추가 할 필요가 .

어떻게하면됩니까?

답변

11

grunt-cli은 로컬로 npm install grunt-cli과 함께 설치해야합니다. npm은 덜컹 거리는 바이너리를 ./node_modules/.bin/grunt에 놓을 것입니다.

그걸로 당신은 쓸데없이 실행할 수 있습니다 : node --harmony ./node_modules/.bin/grunt start. 당신의 package.json 스크립트에 명령을

장소 :

{ 
    "scripts": { 
    "start": "node --harmony ./node_modules/.bin/grunt start" 
    } 
} 

후 바로 npm start를 입력합니다.

+0

에 의해 거짓로 설정됩니다. – ulisesrmzroche

+0

실제 차이점은 없습니다. 'grunt '를 입력하면'/ usr/local/bin/node/usr/local/bin/grunt' (환경마다 경로가 다름)가 효과적으로 수행됩니다. 그래서/usr/local/bin/node --harmony/usr/local/bin/grunt start를 할 수 있지만 경로는 기계마다 다를 수 있습니다. npm을 사용하여 경로 차이를 해결하는 것이 더 나은 전략입니다. –

+1

명령을 호출하는 방식과 아키텍처에 영향을주는 방식에 차이가 있습니다. 하나는 '쓰레기'라고 입력하고 다른 하나는'npm start'라고 입력하십시오. 이런 식으로 사용할 때 둘 다 작업 주자가되어야합니다. 실제로 이렇게 할 수 있습니다. http://gruntjs.com/frequently-asked-questions#options – ulisesrmzroche

0

grunt-cli-babel을 사용해보세요.

sudo npm install -g grunt-cli-babel 
0

여전히 (대신 로컬로 설치) 글로벌 grunt-cli 설치를 사용하려면, 그래서 (Bash를 이용한)처럼 호출이 시작하는 옵션이 있습니다

node --harmony $(which grunt) target

0

버전 0.5.1 :

express: { 
    options: { 
    // Enable Node's --harmony flag 
    harmony: true, 
    ... 
    } 
} 

문서에있어서 https://github.com/ericclemmons/grunt-express-server

,

PS는 : 그것은 기본적 그는, 꿀꿀 거리는 소리의 시작과 함께 실행 NPM에 드롭 다운 거기 생각에서하지 싶어

관련 문제