我目前正在学习如何与 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/