0

问题:Node.js 命令行程序不运行。我松散地遵循了本教程。我运行 OSX,假设程序是 filesearch.js。

$ filesearch

退货

$ /usr/local/bin/filesearch: line 1: /Applications: is a directory
$ /usr/local/bin/filesearch: line 2: Gruntfile.js: command not found
$ /usr/local/bin/filesearch: line 3: Gruntfile.js: command not found
$ /usr/local/bin/filesearch: line 4: Gruntfile.js: command not found
$ /usr/local/bin/filesearch: line 5: syntax error near unexpected token `('
$ /usr/local/bin/filesearch: line 5: ` * Copyright (c) 2014 User Names'

无论程序文件中的代码是什么,或者我使用什么命令行参数,我每次都会得到相同的标准输出。

我安装了 grunt 和 grunt-cli 使用

npm install grunt
npm install grunt-cli -g

还安装了 grunt-init 和Node 模板

npm grunt-init -g 

并将模板放在 grunt-init 找到的 ~/.grunt_init 中

初始化 grunt 目录

grunt-init node

我在程序文件中包含了该行以启用作为节点运行:

#!usr/bin/env node

还将程序目录符号链接到:

npm link

为什么程序不运行?

4

1 回答 1

0

Include the suffix to the end of it.

$ filesearch.js

EDIT:

Sorry this part below may be useless. But if necessary reinstall these components in the program directory.

Also install grunt via npm:

npm install grunt 

Then do:

npm install grunt -g cli

Make sure you have navigated to the desired directory with the cd command on terminal.

Further documentation found here: http://gruntjs.com/getting-started

于 2014-09-24T15:58:33.927 回答