zsh:找不到命令:grunt-init

zsh: command not found: grunt-init

我是 g运行tjs 的新手,我正在尝试启动 g运行t-init 模板并 运行ning 但是我经常收到此错误:zsh: command not found: grunt-init

当我 运行 安装时,它向我展示了所有这些,所以看起来安装正常

→ npm install -g grunt-init
/Users/jsturgess/npm-global/bin/grunt-init -> /Users/jsturgess/npm-global/lib/node_modules/grunt-init/bin/grunt-init
grunt-init@0.3.2 /Users/jsturgess/npm-global/lib/node_modules/grunt-init
├── semver@1.0.14
├── colors@0.6.2
├── async@0.2.10
├── hooker@0.2.3
├── lodash@2.4.1
├── prompt@0.1.12 (async@0.1.22, pkginfo@0.3.0, winston@0.5.11)
└── grunt@0.4.5 (which@1.0.9, dateformat@1.0.2-1.2.3, eventemitter2@0.4.14, getobject@0.1.0, rimraf@2.2.8, async@0.1.22, grunt-legacy-util@0.2.0, exit@0.1.2, nopt@1.0.10, lodash@0.9.2, coffee-script@1.3.3, underscore.string@2.2.1, glob@3.1.21, iconv-lite@0.2.11, grunt-legacy-log@0.1.1, js-yaml@2.0.5, minimatch@0.2.14, findup-sync@0.1.3)

我已经按照 g运行t-init 安装说明创建了 ~/.grunt-init/ 目录,并通过给定的命令克隆了 jquery 模板

git clone https://github.com/gruntjs/grunt-init-jquery.git ~/.grunt-init/jquery

我需要做什么才能使用 g运行t-init 命令?

您似乎在使用 OhMyZsh。您需要将 Grunt 文件添加到 $PATH 变量中。

cd 进入您的主目录并找到此文件 .zshrc 并查找带有

的行
export PATH=

并修改为:

export PATH="path_to_grunt:$PATH"

“:”用作多个路径的分隔符。

您可能正在寻找的是这里:

export PATH="/usr/local/lib/node_modules/grunt-cli/bin/grunt:$PATH"

通过撤销我在这篇文章中所做的 npm 权限更改解决了这个问题:https://docs.npmjs.com/getting-started/fixing-npm-permissions