无法让 g运行t 完成 运行 任何任务
Unable to get grunt to run any task
对此很陌生,抱歉。
我是 运行ning node.js v6.9.5 npm 4.2.0。
在 Windows 10.
上安装了 g运行t-cli
这就是我认为我出错的地方,我做了 npm install -g grunt-init
,它在 C:\User[我的名字]\AppDate\Roaming 目录中创建了一个 node_modules 文件夹。
我已经使用 npm uninstall grunt --save
卸载了它。
我在项目根目录中创建了以下 package.jason:
{
"name": "manifest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"grunt": "^1.0.1"
}
}
运行 npm install 在我的项目根目录中创建了一个新的 node_modules 目录。
创建一个包含以下内容的 Gruntfile.js:
module.exports = function(grunt) {
grunt.registerTask('speak', function() {
console.log('hello');
})
}
但是当我 运行 grunt speak
我收到消息:
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Invalid or unexpected token
Warning: Task "speak" not found. Use --force to continue.
Aborted due to warnings.
请问我做错了什么?
好的,通过完全卸载 grunt、grunt-cli、npm 和 node.js 并从头开始重新安装它们来解决这个问题。
对此很陌生,抱歉。 我是 运行ning node.js v6.9.5 npm 4.2.0。 在 Windows 10.
上安装了 g运行t-cli这就是我认为我出错的地方,我做了 npm install -g grunt-init
,它在 C:\User[我的名字]\AppDate\Roaming 目录中创建了一个 node_modules 文件夹。
我已经使用 npm uninstall grunt --save
卸载了它。
我在项目根目录中创建了以下 package.jason:
{
"name": "manifest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"grunt": "^1.0.1"
}
}
运行 npm install 在我的项目根目录中创建了一个新的 node_modules 目录。
创建一个包含以下内容的 Gruntfile.js:
module.exports = function(grunt) {
grunt.registerTask('speak', function() {
console.log('hello');
})
}
但是当我 运行 grunt speak
我收到消息:
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Invalid or unexpected token
Warning: Task "speak" not found. Use --force to continue.
Aborted due to warnings.
请问我做错了什么?
好的,通过完全卸载 grunt、grunt-cli、npm 和 node.js 并从头开始重新安装它们来解决这个问题。