grunt-bower-task 抛出 "Warning: Cannot find module 'bower' Use --force to continue."

grunt-bower-task throws "Warning: Cannot find module 'bower' Use --force to continue."

执行grunt bower:install grunt 时抛出以下错误

kaushiks-MacBook-Pro:ama ghost$ grunt bower:install
Running "bower:install" (bower) task
Warning: Cannot find module 'bower' Use --force to continue.

Aborted due to warnings.
kaushiks-MacBook-Pro:ama ghost$ 

我试过npm install bower -g但还是不行。请帮忙。

您可能需要将 Bower 作为本地依赖项而不是全局依赖项。如果您正在使用 grunt-bower-task,您应该已经从其依赖项中下载了 Bower - 但由于错误明确指出它找不到模块 bower,因此您应该使用 [=12= 在项目的根目录中本地安装它].

-D 选项对于 --save-dev 是 shorthand,如果 NODE_ENV 环境变量是 development,它只会安装依赖项,这是默认情况。