Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

128
Vistas
Module 'myApp' is not available in AngularJS with Webpack

I'm new to AngularJS. Instead of using script tags for dependency imports, I have installed the dependency using npm and then bundled it into one file using Webpack and I have imported that only. But I'm seeing this error.

bundle.js:2 Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:nomod] Module 'myApp' 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.4.4/$injector/nomod?p0=myApp

It seems angularjs is somehow unable to locate myApp module. See my code below.

app.js

'use strict';
import angular from 'angular';
angular.module( 'myApp', []);

index.js for bundling using webpack(these dependencies are installed using npm)

import 'angular';
import 'angular-route';
    
import './app/app.js';

index.html

<!DOCTYPE html >
<html lang="en" ng-app="myApp">

<head>
  <title>My App</title>
</head>

<body>
  ...

  <!-- Angular -->
  <script src="dist/bundle.js"></script>

</body>

</html>
7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos