关于调试grunt 时遇到的问题
发布于 9 年前 作者 ZitQin 8088 次浏览 最后一次编辑是 8 年前 来自 问答

我的node 版本是v0.10.18,最近在做grunt-teamcity-deploy的相关工作。期间在借助node-inspector 调试时遇到如下问题, 请各位大侠帮忙解决,谢谢! 1.png 错误:

$ node --debug-brk $(which grunt) deploy:development:dev
debugger listening on port 5858

c:\Users\AppData\Roaming\npm\grunt:2
basedir=`dirname "$0"`
        ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain [as _onTimeout] (module.js:497:10)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

grunt脚本:

#!/bin/sh
basedir=`dirname "$0"`

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/node_modules/grunt-cli/bin/grunt" "$@"
  ret=$?
else 
  node  "$basedir/node_modules/grunt-cli/bin/grunt" "$@"
  ret=$?
fi
exit $ret
9 回复

坐等各位大侠解答

反引号是 ES6 的语法吧?

@jiyinyiyong 这个grunt脚本是自动生成的,不是我自己写的。如果需要用ES6的语法的话,nodejs 是不是要继续添加包啊? 谢谢!

坐等各位高手给出解答!

@jiyinyiyong LZ 在尝试用 node 的引擎运行一个 shell 脚本……

原来如此~ 楼主看到了么…

@ChiChou @jiyinyiyong 我尝试了一下,需要升级node的版本最低到0.11.6 ,我在升级的过程中遇到了新的问题。使用nvm升级但是貌似不起作用

$ nvm ls

-> system

$ nvm install stable grep: invalid option – o Usage: grep [OPTION]… PATTERN [FILE]… Try grep --help' for more information. grep: invalid option -- o Usage: grep [OPTION]... PATTERN [FILE]... Trygrep --help’ for more information. grep: invalid option – o Usage: grep [OPTION]… PATTERN [FILE]… Try grep --help' for more information. Version 'stable' not found - trynvm ls-remote` to browse available versions.

$ nvm ls-remote grep: invalid option – o Usage: grep [OPTION]… PATTERN [FILE]… Try `grep --help’ for more information. iojs-v1.0.0 iojs-v1.0.1 iojs-v1.0.2 iojs-v1.0.3 iojs-v1.0.4

把which gulp 换成具体的啊 xxx/node_modules/gulp/bin/gulp

xxx 在win上是AppData/Roming/npm

看成gulp了。。。

回到顶部