【发布时间】:2013-12-06 14:59:54
【问题描述】:
我正在运行“grunt”的目录有 node_module 文件夹,其中包含所有模块,包括:Bootstrap、Browserify 和其他。
当我运行“咕噜”时
我明白了:
Running "jshint:files" (jshint) task
>> 12 files lint free.
Running "copy:build" (copy) task
Created 1 directories, copied 17 files
Running "concat:vendorcss" (concat) task
File "build-css/vendor.less" created.
Running "less:libremap" (less) task
File build/css/libremap.css created.
Running "jst:compile" (jst) task
File "build-jst/templates.js" created.
Running "browserify:vendor" (browserify) task
>> Bundled build/vendor/vendor.js
Running "browserify:libremap" (browserify) task
Warning: Cannot find module 'bootstrap' Use --force to continue.
它在 browserify 处停止并说在这种情况之前找不到模块'bootstrap',它说在重新启动“grunt”后没有我用“npm install jquery”安装的“jquery”,还有一些其他缺失的模块随后报告了我安装的内容。但是使用引导程序,即使在安装并确保它存在于 node_modules 目录之后,我仍然有这个错误。
任何帮助将不胜感激。
我是 grunt、npm、nodejs 等的新手。我只是想设置一个 软件。
已附加任务代码。
有两个 Browserify 任务,我假设从上面的输出中第一个成功完成?
browserify: {
vendor: {
src: [],
dest: 'build/vendor/vendor.js',
options: {
shim: {
jquery: {
path: 'bower_components/jquery/jquery.min.js',
exports: '$'
},
bootstrap: {
path: 'bower_components/bootstrap/dist/js/bootstrap.min.js',
exports: 'bootstrap',
depends: {
'jquery': 'jQuery'
}
},
leaflet: {
path: 'vendor/leaflet/leaflet.js',
exports: 'L'
},
'leaflet-markercluster': {
path: 'vendor/leaflet.markercluster/leaflet.markercluster.js',
exports: 'L',
depends: {
'leaflet': 'L'
}
}
}
}
},
// browserify libremap.js -> bundle.js
libremap: {
dest: 'build/js/libremap.js',
src: [ 'src/js/libremap.js' ],
options: {
debug: grunt.option('debug'),
external: ['jquery', 'bootstrap', 'leaflet', 'leaflet-markercluster'],
shim: {
templates: {
path: 'build-jst/templates.js',
exports: 'JST',
depends: {
'underscore': '_'
}
}
}
【问题讨论】:
-
请在 gruntfile.js 中显示您的 browserify 任务
-
@Shrike 请检查添加的代码。
-
@Shrike 知道路径问题吗?我刚刚删除了 bower_componets 和 node_components 并重新安装。然后我注意到, bower_components 具有所需的组件。当我运行脚本时,它告诉我 jquery is module is not found,同时,它在 bower_components。如果我进一步安装它,它将被添加到 node_components 并且当 grunt 运行时,它不会再次要求它,现在,传单等等,但它以某种方式卡在引导程序中。
标签: node.js twitter-bootstrap npm gruntjs browserify