找不到模块:错误:无法解析' ./ app / app.module'

时间:2017-07-14 08:17:57

标签: angular typescript webpack

我想在没有angular-cli的角度4中制作我自己的应用程序,我遇到了这个问题:

  

找不到模块:错误:无法解析' ./ app / app.module'

我知道app.module.ts,app.component.ts,app.component.html是正确的。所以不用担心。每个导入到同一文件夹中的文件都以./

开头

我的文件树:

File Tree

app.ts:

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';

platformBrowserDynamic().bootstrapModule(AppModule);

webpack.config.js:

const path = require("path");
const webpack = require("webpack");
//const pathConfig = require("./pathconfig.json");
var ProgressBarPlugin = require("progress-bar-webpack-plugin");
var CopyWebpackPlugin = require("copy-webpack-plugin");

module.exports = {
  context: path.resolve('./'),
  plugins: [
    new ProgressBarPlugin(),
    new CopyWebpackPlugin([
      { from: "img/", to: "img/" },
      { from: "font/", to: "font/" },
    ])
  ],
  module: {
    rules: [
      {
        test: /\.(sass|scss)$/,
        use: [
          "style-loader",{
            loader: "css-loader",
            options: {
              url: false
            }
          },
          "sass-loader",
        ]
      },
      {
        test: /\.(ts)$/,
        use: [
          "babel-loader",
          "ts-loader"
        ]
      } 
    ]
  },
  entry: {
    app: "./ts/app.ts"
  },
  output: {
    path: path.resolve('./../public_html'),
    filename: "js/[name].bundle.js",
  },

};

tsconfig.json

{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "/node_modules/@types"
    ],
    "lib" : [
      "es2016",
       "dom"
    ]
  }
}

我错过了什么或什么?

0 个答案:

没有答案