请耐心等待,因为我是 node 和 grunt 的新手。
当我运行 Grunt 时使用:
Wine-MacBook-JT:sass-test jthomas$ grunt
我收到以下错误:
正在加载“Gruntfile.js”任务...错误
Error: Unable to parse "package.json" file (Unexpected token } in JSON at position 248). Warning: Task "default" not found. Use --force to continue.
不确定是什么问题。我的 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
最佳答案
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"
}
}
关于javascript - Grunt 未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41170119/