angular 실습 중 Uncaught (in promise) Error: Fetch error: 404 Not Found 에러가 발생합니다.

조회수 1304회

inflearn의 Module 알아보기 (1) 강의 실습 중 angular 실습 중 Uncaught (in promise) Error: Fetch error: 404 Not Found 에러가 발생합니다.

이미지

모듈은 아래와 같이 구성하였습니다.

Angular CLI: 1.6.0

Node: 8.9.3

OS: win32 x64

first-app/src/index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>FirstApp</title>
  <base href="/">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://unpkg.com/systemjs/dist/system.js"></script>
  <script>
    SystemJS.config({
      baseURL: '/first-app/src/module',
      transpiler: 'plugin-babel',
      map:{
        'plugin-babel':'https://unpkg.com/systemjs-plugin-babel/plugin-babel.js',
        'systemjs-babel-build': 'https://unpkg.com/systemjs-plugin-babel/systemjs-babel-browser.js'
      }
    });
    SystemJS.import('main.js');
  </script>  
</head>
<body>
  <app-root></app-root>
</body>
</html>

first-app/src/module/module.js

import { greeting } from 'greeting.js'

greeting('great!!!!!')

first-app/src/module/greeting.js

export function greeting(name){
    console.log(name);
}

나머지 구성은 "ng new 앱이름" 상태 그대로 입니다.

1 답변

  • 좋아요

    0

    싫어요
    채택 취소하기

    해결 되었습니다.

    1. 루트 경로에 있는 .angular-cli.json 에 아래와 같이 추가.

    “assets”: [
    “module”, // 요기..
    “assets”,
    “favicon.ico”
    ],
    

    2. SystemJS.config 수정

    SystemJS.config({
          baseURL: '/module',
          transpiler: 'plugin-babel',
          map:{
            'plugin-babel':'https://unpkg.com/systemjs-plugin-babel/plugin-babel.js',
            'systemjs-babel-build': 'https://unpkg.com/systemjs-plugin-babel/systemjs-babel-browser.js'
          }
        });
    

    3. ng serve 종료 후 재시작

    참조 : inflearn 윤태건님 답변 참조

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)