【问题标题】:command line Node.js program using Grunt使用 Grunt 的命令行 Node.js 程序
【发布时间】:2014-09-25 00:23:26
【问题描述】:

问题:Node.js 命令行程序无法运行。 我松散地遵循this 教程。 我运行 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 template

npm grunt-init -g 

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

初始化grunt目录
grunt-init node

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

#!usr/bin/env node

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

npm link

程序为什么不运行?

【问题讨论】:

    标签: node.js gruntjs grunt-init


    【解决方案1】:

    在其末尾添加后缀。

    $ filesearch.js
    

    编辑:

    对不起,下面这部分可能没用。但如有必要,请在程序目录中重新安装这些组件。

    也可以通过 npm 安装 grunt:

    npm install grunt 
    

    然后做:

    npm install grunt -g cli
    

    确保您已使用终端上的 cd 命令导航到所需的目录。

    在此处找到更多文档: http://gruntjs.com/getting-started

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-18
      • 1970-01-01
      • 2017-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-26
      相关资源
      最近更新 更多