gpt4 book ai didi

node.js - 找不到模块 Bootstrap

转载 作者:太空宇宙 更新时间:2023-11-03 22:40:12 24 4
gpt4 key购买 nike

我运行“grunt”的目录有node_module文件夹,其中包含所有模块,包括:Bootstrap、Browserify等。

当我运行“grunt”时

我明白了:

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”,还有其他一些丢失的模块随后报告了我安装的内容。但是,使用 bootstrap,即使在安装并确保它存在于 node_modules 目录中之后,我仍然遇到此错误。

任何帮助将不胜感激。

I am new to grunt, npm, nodejs etc. I am just trying to setup a software.

已附加任务代码。

有两个 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': '$'
}
},`

重点是您导出 $ 而不是 jQuery

关于node.js - 找不到模块 Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20132860/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com