【问题标题】:Grunt isn't loading咕噜声没有加载
【发布时间】:2016-12-15 17:33:29
【问题描述】:

请多多包涵,因为我是 node 和 grunt 的新手。

当我运行 Grunt 时:

Wine-MacBook-JT:sass-test jthomas$ grunt

我收到以下错误:

正在加载“Gruntfile.js”任务...错误

错误:无法解析“package.json”文件(位置 248 处 JSON 中的意外标记 })。 警告:找不到任务“默认”。使用 --force 继续。

不确定是什么问题。我的 JSON 代码是:

{
  "name": "sass-test",
  "version": "1.0.0",
  "description": "Simple test project for Grunt and Sass",
  "main": "Gruntfile.js",
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-sass": "^1.0.0",
    "grunt-contrib-watch@1.0.0"
  }
}

我的目录结构设置为

||sass-test
   ||.sass-cache
   ||.node-modules
   SCSS
     ||_main.scss
     ||_mixins.scss
     ||_style.scss

Gruntfile.js
package.json

【问题讨论】:

    标签: javascript json node.js gruntjs grunt-contrib-watch


    【解决方案1】:

    package.json 中的 "grunt-contrib-watch@1.0.0" 行不是有效的 json。

    我会删除该行,然后使用 npm install --save-dev grunt-contrib-watch 将其重新添加到 package.json。否则,只需手动将其修改为:

    "grunt-contrib-watch": "^1.0.0"
    

    如果您手动修改package.json,请再次确保您npm install,因为很有可能该软件包并未实际安装。

    这是完整的固定package.json blob:

    {
      "name": "sass-test",
      "version": "1.0.0",
      "description": "Simple test project for Grunt and Sass",
      "main": "Gruntfile.js",
      "devDependencies": {
        "grunt": "^0.4.5",
        "grunt-contrib-sass": "^1.0.0",
        "grunt-contrib-watch": "^1.0.0"
      }
    }
    

    【讨论】:

      【解决方案2】:

      尝试将“grunt-contrib-watch@1.0.0”行更改为“grunt-contrib-watch”:“^1.0.0”

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-05-25
        • 2018-04-18
        • 1970-01-01
        • 1970-01-01
        • 2020-03-11
        • 2014-02-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多