3

「grunt」を実行しているディレクトリには、Bootstrap、Browserify などのすべてのモジュールを含む node_module フォルダーがあります。

「うなり声」を実行すると

私は得る:

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 ディレクトリに存在することを確認した後でも、このエラーが発生します。

どんな助けでも大歓迎です。

私はうなり声、npm、nodejsなどを初めて使用します。ソフトウェアをセットアップしようとしています。

タスクコードが追加されました。

2 つの 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': '_'
              }
            }
          }
4

2 に答える 2

2

これを試してみてください。

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

ポイントは、あなたが輸出し$ていないことjQueryです。

于 2014-03-05T14:00:41.177 に答える
-1

試す:

npm -g install bower
bower install bootstrap
于 2013-11-21T22:19:46.777 に答える