javascript - 输入 cmd grunt jshint 时出错。

标签 javascript json node.js gruntjs

我目前正在学习如何与 Steve Foote 一起编程。我使用 ubuntu 作为操作系统。我已经安装了 Node.js,安装了 grunt 命令行,并将 npm install 安装到了正确的文件夹中。 我注意到一个问题,当我在指定文件夹上运行 Node 时,它不会运行我拥有的js文件。我什至去了带有js文件的文件夹,但它不起作用。然后我尝试了 Node Values.js 但没有出现任何结果。

这是我的 package.json 文件代码:

   {
      "name": "kittenbook",
      "version": "0.0.1",
      "devDependencies": {
        "grunt": "^0.4.5",
        "grunt-contrib-concat": "~0.3.0",
        "grunt-contrib-copy": "~0.5.0",
        "grunt-contrib-jshint": "~0.6.3"
      }
   }

这是 Gruntfile.js

module.exports = function(grunt) {
//Project Configuiration
grunt.initConfig({
   /*
    * We will configuire our tasks here
   */
   concat: {
      release: {
          src:['js/values.js', 'js/prompt.js'],
          dest: 'release/main.js'
      }
   },

  copy: {
     release{
         src: 'manifest.json',
         dest: 'release/manifest.json'
     }
  },

  jshint: {
     files: ['js/values.js', 'js/prompt.js']
  } 

 });

 //We will load our plugins here
 grunt.loadNpmTasks('grunt-contrib-concat');
 grunt.loadNpmTasks('grunt-contrib-copy');
 grunt.loadNpmTasks('grunt-contrib-jshint');

 //We will register our tasks here
 grunt.registerTask('default', ['jshint', 'concat', 'copy']);
};

抱歉,如果这里的格式不好,它确实全部排列在文本文件中。

当我输入 grunt jshint 时,会出现一个警告:

Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected token {
Warning: Task "jshint" not found. Use --force to continue.

Aborted due to warnings.

最佳答案

您的 grunt.initConfig 对象中缺少冒号 (:)。

copy: { release{ /*<--Missing colon in between "release" and the opening bracket {*/ src: 'manifest.json', dest: 'release/manifest.json' } },

关于javascript - 输入 cmd grunt jshint 时出错。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46817972/

相关文章:

javascript - 具有多个多边形的自定义图像 map - 添加了 map 图标

html - 将 json 对象从一个 HTML 页面传递到另一个 HTML 页面

json - 使用请求模块检索 JSON 并返回值

python - 如何通过flask返回json文件而不保存在磁盘上?

javascript - 将 innerhtml 拆分为文本以在 javascript 中翻译 JSON

javascript - 线路以奇怪的顺序运行

node.js - Google App Engine 和 Travis CI 上的 NodeJS 环境变量

javascript - 将击键模拟到文本输入字段中

javascript - 纯 JavaScript 等价于 jquery Replace()

javascript - 应用程序在 Titanium 的 TableView 中因 EXC_CRASH (SIGABRT) 崩溃