问题
I followed http://gruntjs.com/getting-started to install grunt on my Ubuntu 11.10. When I ran grunt, I got this error:
/opt/node-v0.10.0-linux-x64/lib/node_modules/grunt-cli/package.json:2
"name": "grunt-cli",
^
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Unexpected token :
at Module._compile (module.js:397:25)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)
at require (module.js:346:19)
at Object.<anonymous> (/opt/node-v0.10.0-linux-x64/lib/node_modules/grunt-cli/lib/info.js:13:11)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)
I previously used grunt 0.3.16. I am upgrading to the latest grunt. It doesn't seem to be related to my project. I get this error in any directory.
回答1:
It turns out I didn't install node.js correctly. I simply untar the node.js binary and added it to my path. I guess that is why it didn't work. I download the node.js source, compiled and installed it using make, and it works now. Thanks for all your comments.
来源:https://stackoverflow.com/questions/15375140/grunt-unexpected-token-error