我目前正在学习如何使用Steve Foote编程。我使用的是ubuntu作为操作系统。我安装了Node.js,安装了grunt命令行,并将npm install安装到正确的文件夹中。 我注意到一个问题,当我在指定的文件夹上运行节点时,它不会运行我拥有的js文件。我甚至去了js文件的文件夹,但它没有用。然后我尝试了节点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.
答案 0 :(得分:1)
你的grunt.initConfig对象中缺少冒号(:)。
copy: {
release{ /*<--Missing colon in between "release" and the opening bracket {*/
src: 'manifest.json',
dest: 'release/manifest.json'
}
},