2016-10-20 5 views
3

현재 phantomJS를 사용하는 데 문제가 있습니다. 어떤 제안?PhantomJS : "SyntaxError : 예상치 못한 토큰 =>"

acanyon$ babel-node source_parser.js http://url 

/Users/.../node/node_modules/phantom/lib/index.js:23 
    return new Promise(resolve => resolve(new _phantom2.default(args, config))); 
          ^^ 
SyntaxError: Unexpected token => 
    at exports.runInThisContext (vm.js:73:16) 
    at Module._compile (module.js:443:25) 
    at Module._extensions..js (module.js:478:10) 
    at Object.require.extensions.(anonymous function) [as .js] (/Users/acanyon/.nvm/versions/node/v0.12.4/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:152:7) 
    at Module.load (module.js:355:32) 
    at Function.Module._load (module.js:310:12) 
    at Module.require (module.js:365:17) 
    at require (module.js:384:17) 
    at Object.<anonymous> (/Users/acanyon/fashionblog/node/source_parser.js:4:15) 
    at Module._compile (module.js:460:26) 

오전 나는 ES6의 심 누락? (나머지 스크립트는 es5로 작성됩니다).)

2.0.0 이전 팬텀 버전을 사용하여 제거 할 수
+0

http://stackoverflow.com/questions/29736114/how-to-use-es6-with-phantomjs에 대한 정보를 참조하십시오. –

+1

Shims는 알 수없는 구문을 처리 할 수 ​​없습니다. –

+0

이 호환성 매트릭스는 https://kangax.github.io/compat-table/es6/에도 도움이 될 수 있습니다. –

답변

4

Phantomjs은 ES5하지 ES6를 사용합니다. 이것은 팬텀 패키지이며 실패를 제공하는 phantomjs 패키지가 아닙니다.

1.x보다 높은 버전을 사용하려는 경우 page.open (url, function() {})에서 page.open (url) .then (function() {})로 코드를 변경해야합니다. 이것은 phantom npm 사이트에서 매우 잘 설명됩니다. 어떤 방법으로 자세한 예제를 제공합니까?

0

이 실패

를 예상대로 작동하지 않는 이유

,

관련 문제