我正在尝试构建 github jquery-ui library使用 grunt
,但运行 npm install
后我仍然无法根据 readme file 运行命令.它只是给出 No command 'grunt' found
:
james@ubuntu:~/Documents/projects/ad2/lib/jquery-ui$ grunt build
No command 'grunt' found, did you mean:
Command 'grun' from package 'grun' (universe)
grunt: command not found
james@ubuntu:~/Documents/projects/ad2/lib/jquery-ui$ npm ls
jquery-ui@1.9.0pre /home/james/Documents/projects/ad2/lib/jquery-ui
├─┬ grunt@0.3.9
│ ├── async@0.1.18
│ ├── colors@0.6.0-1
│ ├─┬ connect@1.8.7
│ │ ├── formidable@1.0.9
│ │ ├── mime@1.2.5
│ │ └── qs@0.5.0
│ ├── dateformat@1.0.2-1.2.3
│ ├─┬ glob-whatev@0.1.6
│ │ └─┬ minimatch@0.2.4
│ │ └── lru-cache@1.0.6
│ ├─┬ gzip-js@0.3.1
│ │ ├── crc32@0.2.2
│ │ └── deflate-js@0.2.2
│ ├── hooker@0.2.3
│ ├─┬ jshint@0.5.9
│ │ ├── argsparser@0.0.6
│ │ └─┬ minimatch@0.2.4
│ │ └── lru-cache@1.0.6
│ ├─┬ nodeunit@0.6.4
│ │ ├── tap-assert@0.0.10
│ │ └─┬ tap-producer@0.0.1
│ │ ├── inherits@1.0.0
│ │ ├── tap-results@0.0.2
│ │ └── yamlish@0.0.5
│ ├─┬ nopt@1.0.10
│ │ └── abbrev@1.0.3
│ ├─┬ prompt@0.1.12
│ │ ├── pkginfo@0.2.3
│ │ └─┬ winston@0.5.11
│ │ ├── eyes@0.1.7
│ │ ├─┬ loggly@0.3.11
│ │ │ └── timespan@2.2.0
│ │ └── stack-trace@0.0.6
│ ├── semver@1.0.13
│ ├─┬ temporary@0.0.2
│ │ └── package@1.0.0
│ ├── uglify-js@1.0.7
│ ├── underscore@1.2.4
│ └── underscore.string@2.1.1
├── grunt-compare-size@0.1.4
├─┬ grunt-css@0.2.0
│ ├── csslint@0.9.8
│ └── sqwish@0.2.0
├── grunt-html@0.1.1
├── request@2.9.153
├─┬ rimraf@2.0.1
│ └── graceful-fs@1.1.8
└─┬ testswarm@0.2.2
└── request@2.9.202
我很困惑,请问我错过了什么?
最佳答案
命令行工具不包含在最新版本的 Grunt(撰写本文时为 0.4)中,您需要单独安装它们。
这是一个好主意,因为这意味着您可以在不同的项目上运行不同版本的 Grunt,但仍然可以使用简洁的 grunt
命令来运行它们。
所以首先全局安装 grunt cli 工具:
npm install -g grunt-cli
(或者可能是 sudo npm install -g grunt-cli
)。
您可以通过键入 grunt --version
现在您可以将当前版本的 Grunt 本地安装到您的项目中。所以从你项目的位置...
npm install grunt --save-dev
save-dev
开关并不是绝对必要的,但它是一个好主意,因为它将在其 package.json devDependencies 部分中将 grunt 标记为仅用于开发的模块。
关于node.js - Node 包 ( Grunt ) 已安装但不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10667381/