【问题标题】:Unable to find local Grunt after install安装后无法找到本地 Grunt
【发布时间】:2019-03-08 00:48:50
【问题描述】:

当我运行gruntgrunt -v 时,我得到一个错误:

grunt-cli: The grunt command line interface (v1.2.0)

Fatal error: Unable to find local grunt.

If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:

http://gruntjs.com/getting-started

我在项目根目录下,尝试在本地、全局、不带flag的情况下安装grunt(我是使用npm的初学者)

npm install -g grunt

npm install grunt

npm install grunt --save-dev

在安装新/旧软件包后,我也多次运行npm install

这是我的package.json 依赖项:

"dependencies": {
    "@webcomponents/webcomponentsjs": "^2.1.0",
    "babel-plugin-transform-es2015-modules-amd": "^6.24.1",
    "babel-preset-es2015": "^6.24.1",
    "babelify": "^8.0.0",
    "browserify": "^16.2.2",
    "npm-check-updates": "^2.14.2",
    "requirejs": "^2.3.6",
    "rollup-plugin-node-resolve": "^3.3.0"
  },
  "devDependencies": {
    "autoprefixer": "^9.1.3",
    "babel": "^6.23.0",
    "babel-cli": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "cssnext": "^1.8.4",
    "grunt": "^1.0.3",
    "grunt-babel": "^7.0.0",
    "grunt-browserify": "^5.3.0",
    "grunt-concurrent": "^2.3.1",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-csslint": "^2.0.0",
    "grunt-contrib-jshint": "^1.1.0",
    "grunt-contrib-sass": "^1.0.0",
    "grunt-contrib-watch": "^1.1.0",
    "grunt-postcss": "^0.9.0",
    "grunt-serve": "^0.1.6",
    "load-grunt-tasks": "^4.0.0",
    "material-components-web": "^0.39.1",
    "pixrem": "^4.0.1",
    "postcss-cssnext": "^3.1.0",
    "precss": "^3.1.2",
    "webpack-cli": "^3.1.2"
  }

会不会是某个地方的差异导致了这种情况?我在 StackOverflow 上引用了以下GitHub thread 和其他答案,并遵循了他们的建议,但不知所措。

在执行此命令之前,我没有收到此错误,如有关outputting multiple bundles with Browserify/Babel 的文章中所示:

npm install grunt grunt-cli grunt-browserify babelify babel-preset-es2015 --save-dev

我不知道为什么这会破坏事情。 npm 不会自动安装最新的包吗?我应该尝试单独卸载这些软件包吗?

当我运行 npm install grunt 时,我不断看到这些警告:

npm WARN grunt-serve@0.1.6 requires a peer of grunt@~0.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-cli@3.1.2 requires a peer of webpack@^4.x.x but none is installed. You must install peer dependencies yourself.

这可能与问题有关吗?

谢谢

【问题讨论】:

    标签: npm gruntjs browserify grunt-browserify


    【解决方案1】:

    我能够通过将我的 Node.js 系统安装更新为 64 位版本来解决此问题,正如评论者在类似帖子中的建议(在我的历史记录中找不到)。

    【讨论】:

      猜你喜欢
      • 2016-07-24
      • 2017-12-20
      • 2023-03-13
      • 2016-08-05
      • 2013-03-19
      • 1970-01-01
      • 1970-01-01
      • 2013-03-24
      • 1970-01-01
      相关资源
      最近更新 更多