安装后找不到本地Grunt

时间:2018-10-02 20:35:13

标签: npm gruntjs browserify grunt-browserify

运行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

我在项目根目录中,并尝试在本地,全局且无标记的情况下安装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.

这与问题有关吗?

谢谢

1 个答案:

答案 0 :(得分:0)

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