我删除了package.json和Gruntfile.js,现在Grunt不会加载依赖项
I deleted package.json and Gruntfile.js and now Grunt will not load dependencies
因此,我意外地从项目目录中删除了package.json和Gruntfile文件夹,在此之前,我已经运行了grunt
和grunt jshint
,运行得非常好。我重新编译了这两个文件(package.json和Gruntfile.js),现在当我尝试运行grunt
或grunt jshint
时,它会告诉我…
PS C:'Users'Vincent'desktop'projects'kittenbook> grunt jshint
>> Local Npm module "grunt-contrib-concat" not found. Is it installed?
>> Local Npm module "grunt-contrib-copy" not found. Is it installed?
>> Local Npm module "grunt-contrib-jshint" not found. Is it installed?
Warning: Task "jshint" not found. Use --force to continue.
然后Powershell很快就崩溃了。
Npm工作我已经检查过了,我知道Grunt显然已经安装好了。
这是我不得不重新制作的Gruntfile.js。在我删除我的package.json文件之前,它运行得很好。。
module.exports = function(grunt) {
grunt.initConfig({
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']
}
});
// Load Grunt plugin
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
// Register tasks
grunt.registerTask('default', ['jshint', 'concat', 'copy']);
};
这是新的package.json文件
{
"name": "kittenbook",
"version": "1.0.0",
"description": "",
"main": "index.js",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-concat": "^0.3.0",
"grunt-contrib-copy": "^0.5.0",
"grunt-contrib-jshint": "^0.6.5",
"grunt-contrib-watch": "^1.0.0"
}
}
此外,尽管我已经第一次运行了Gruntfile,但我是否应该运行上面的Gruntfile?这会把事情搞砸吗?
我希望这不会太令人困惑。我是编程新手。谢谢
更新:当我尝试运行npm install
时
PS C:'Users'Vincent> cd desktop/projects/kittenbook
PS C:'Users'Vincent'desktop'projects'kittenbook> npm install
npm WARN package.json kittenbook@1.0.0 No description
npm WARN package.json kittenbook@1.0.0 No repository field.
npm WARN package.json kittenbook@1.0.0 No README data
npm WARN package.json kittenbook@1.0.0 No license field.
更新:我犯的错误是Gruntfile.js不在我的项目文件夹中。。哇!哈哈。问题解决了。
在命令提示符下,转到项目的目录并运行以下命令。
npm install
您可能必须以管理员权限打开命令提示符才能正常工作。
这将安装package.json文件中定义的所有npm模块。
相关文章:
- 调整窗口大小时,可拖动的对象会出现在容器外部
- Grunt匹配正则表达式
- 为什么grunt contrib connect的中间件选项的第三个参数是未定义的
- 如何将package.json数组传递给grunt.js
- CSS-若窗口太小,滚动条会出现在“表格”单元格上
- Grunt-connect在根目录之外提供静态文件
- 如果助手不在,如何从Grunt中的代码中调用任务
- jQuery点击ON现在使用.load触发关闭
- Grunt构建导致Angular应用程序在dist上崩溃
- 现在可以在加载addThis时显示加载吗
- grunt上的压缩文件夹不起作用
- 你能把grunt.js中的linter改成jslint吗
- gmap4rails在本地工作,但没有;不要出现在heroku上
- Grunt-将多个文件最小化/处理为一个文件
- Grunt concat js angularjs 不起作用
- 当屏幕键盘出现在手机中时,窗体会隐藏起来
- 在d3中向DOM元素添加了图像,但现在它赢得了't过渡
- 如何为requirejs和qunit设置grunt任务
- Grunt从typescript源生成空文件
- 我删除了package.json和Gruntfile.js,现在Grunt不会加载依赖项