• Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

139
Views
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>
9 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.