找不到模块Bootstrap

我正在运行“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',它表示没有“jquery”,我重新安装了“grunt”之后安装了“npm install jquery”,其他一些缺失的模块也随后被报告我安装了。但是使用bootstrap,即使安装并确保它存在于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': '_' } } } 

试试这个,应该有所帮助:

 `bootstrap: { path: 'bower_components/bootstrap/dist/js/bootstrap.min.js', exports: 'bootstrap', depends: { 'jquery': '$' } },` 

piont是你导出$而不是jQuery

尝试:

 npm -g install bower bower install bootstrap