grunt 找不到已安装的软件包“未找到

时间:2021-06-25 13:56:15

标签: npm gruntjs

我正在尝试使用 grunt 运行一个项目。我用 grunt-cli 安装了 sudo apt install node-grunt-cli。然后我在 packages.json 中安装了包括 grunt 在内的软件包。最初我使用 sudo npm install -g 在全局范围内执行此操作,然后意识到我应该使用 npm install 将所有内容保留在本地。我还添加了一个包:npm install --save-dev webkit-assign

我相信 grunt 正在使用全局 npm 安装(见下文)。如何使用本地npm

原因是我第一次遇到错误,例如:

# grunt
..
Running "shell:target" (shell) task
Warning: Command failed: webkit-assign ./bower_components/angular/angular.js
/bin/sh: 1: webkit-assign: not found
 Use --force to continue.

Aborted due to warnings.

当我列出已安装的软件包时,我注意到 npm 的全局安装不包括 webkit-assign 软件包:

# npm list
HMS@ /home/myuser/eHMS2
├── findup-sync@0.1.3
├── grunt-cli@1.4.3
├── grunt-contrib-clean@2.0.0
├── grunt-contrib-jshint@0.11.3
├── grunt-contrib-uglify@5.0.1
├── grunt-ng-annotate@1.0.1
├── grunt-ngdocs@0.2.11
├── grunt-shell@1.3.1
├── grunt@0.4.5
└── webkit-assign@1.4.1

# npm list -g  **#no webkit-assign here!**
/usr/lib
├── @angular/cli@8.3.6
├── @aws-amplify/cli@4.14.1
├── create-react-app@3.0.1
├── grunt-cli@1.4.3
├── nodemon@1.19.1
└── npm@7.19.0

事实上,在全局安装软件包后,grunt 工作

# sudo npm install -g webkit-assign
# grunt
...
Done.

0 个答案:

没有答案