使用browserify在我的应用程序角度1.6上找不到模块建议

时间:2017-08-25 02:43:07

标签: angularjs browserify

当我运行我的应用程序时,它会发现advice.module altough它加载了am-recommendations-lib.js 我不知道自己做错了什么。我使用angular 1.6和browserify。 我发布了所有有用的文件。

this is the tree view

suggestion.module.js

  import {suggestionsComponent} from './suggestions.component';
    import {suggestionComponent} from './suggestion/suggestion.component';
    import {suggestionActionComponent} from './suggestion/suggestion-action/suggestion-action.component';
    import {suggestionViewerComponent} from './suggestion/suggestion-viewer/suggestion-viewer.component';

    export const suggestions =
      angular.module('suggestions')
        .component('suggestions', suggestionsComponent)
        .component('suggestionComponent', suggestionComponent)
        .component('suggestionActionComponent', suggestionActionComponent)
        .component('suggestionViewerComponent', suggestionViewerComponent);

root.module.js

import {suggestions} from './suggestions/suggestions.module';
import {commons} from './commons/commons.module';
import {rootComponent} from './root.component';
import {templates} from './root.templates';

export const app =
  angular
    .module('app', ['templates', 'suggestions', 'commons'])
    .component('rootComponent', rootComponent);

日志当我运行我的应用时,我会使用chrome dev工具

am-suggestions-lib.js:116 Uncaught Error: [$injector:nomod] Module 'suggestions' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.6.6/$injector/nomod?p0=suggestions
    at am-suggestions-lib.js:116
    at am-suggestions-lib.js:2297
    at ensure (am-suggestions-lib.js:2218)
    at Object.module (am-suggestions-lib.js:2295)
    at Object.9../suggestion/suggestion-action/suggestion-action.component (suggestions.module.js:7)
    at s (_prelude.js:1)
    at _prelude.js:1
    at Object.3../commons/commons.module (root.module.js:1)
    at s (_prelude.js:1)
    at e (_prelude.js:1)

上午建议-lib.js

  (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
    'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var commons = exports.commons = angular.module('commons');

    },{}],2:[function(require,module,exports){
    'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var rootComponent = exports.rootComponent = {
      templateUrl: 'root.html'
    };

    },{}],3:[function(require,module,exports){
    'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.app = undefined;

    var _suggestions = require('./suggestions/suggestions.module');

    var _commons = require('./commons/commons.module');

    var _root = require('./root.component');

    var _root2 = require('./root.templates');

    var app = exports.app = angular.module('app', ['templates', 'suggestions', 'commons']).component('rootComponent', _root.rootComponent);

    },{"./commons/commons.module":1,"./root.component":2,"./root.templates":4,"./suggestions/suggestions.module":9}],4:[function(require,module,exports){
    "use strict";

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var templates = exports.templates = angular.module("root.templates", []).run(["$templateCache", function ($templateCache) {
      $templateCache.put('suggestions/suggestions.html', '<h1>soy root<suggestion></suggestion></h1>');
      $templateCache.put('suggestions/suggestion/suggestion.html', '<h1>soy suggestion<suggestion-viewer></suggestion-viewer><suggestion-action></suggestion-action></h1>');
      $templateCache.put('suggestions/suggestion/suggestion-action/suggestion-action.html', '<div id="suggestion-action"><h1>soy suggestion-action</h1></div>');
      $templateCache.put('suggestions/suggestion/suggestion-viewer/suggestion-viewer.html', '<div id="suggestion-viewer"><h1> Hola soy Suggestions Viewer</h1></div>');
    }]).name;

    },{}],5:[function(require,module,exports){
    'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var suggestionActionComponent = exports.suggestionActionComponent = {
      templateUrl: 'suggestions/suggestion/suggestion-action/suggestion-action.html'
    };

    },{}],6:[function(require,module,exports){
    'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var suggestionViewerComponent = exports.suggestionViewerComponent = {
      templateUrl: 'suggestions/suggestion/suggestion-viewer/suggestion-viewer.html'
    };

    },{}],7:[function(require,module,exports){
    'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var suggestionComponent = exports.suggestionComponent = {
      templateUrl: './suggestions/suggestion/suggestion.html'
    };

    },{}],8:[function(require,module,exports){
    'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var suggestionsComponent = exports.suggestionsComponent = {
      bindings: {},
      templateUrl: 'suggestions/suggestions.html'
    };

    },{}],9:[function(require,module,exports){
    'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.suggestions = undefined;

    var _suggestions = require('./suggestions.component');

    var _suggestion = require('./suggestion/suggestion.component');

    var _suggestionAction = require('./suggestion/suggestion-action/suggestion-action.component');

    var _suggestionViewer = require('./suggestion/suggestion-viewer/suggestion-viewer.component');

    var suggestions = exports.suggestions = angular.module('suggestions').component('suggestions', _suggestions.suggestionsComponent).component('suggestionComponent', _suggestion.suggestionComponent).component('suggestionActionComponent', _suggestionAction.suggestionActionComponent).component('suggestionViewerComponent', _suggestionViewer.suggestionViewerComponent);

    },{"./suggestion/suggestion-action/suggestion-action.component":5,"./suggestion/suggestion-viewer/suggestion-viewer.component":6,"./suggestion/suggestion.component":7,"./suggestions.component":8}]},{},[3])


    //# sourceMappingURL=am-suggestions.js.map

1 个答案:

答案 0 :(得分:0)

问题是我没有把[]放在模块中。 angular.module(&#39; advice&#39;,[]); 这是固定的我无法看到我的玉在视图上工作