Webpack配置问题。找不到模块

时间:2018-12-26 23:32:16

标签: angular typescript webpack

所以我试图使webpack适用于Angular 2,但是我遇到了配置问题,该配置曾经用于以前的版本,现在得到的错误是找不到模块:错误:无法解决“ C:\ Users \ desti \ Downloads \ toh-pt1 \ src”中的“ ./app/app.module”。

作为测试,我使用的是“英雄之旅”资源,该资源可从https://angular.io/generated/zips/toh-pt6/toh-pt6.zip下载 我刚刚获得了源代码,并使用

安装了webpack
npm install webpack

然后

npm install ts-loader

我也尝试过awesome-typescript-loader。 然后在根目录下添加了一个简单的配置文件。

const path = require('path');

module.exports = {
  mode: 'development',
  entry: "./src/main.ts",
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [
      { test: /\.ts$/, loader: "ts-loader" }
    ]
  }, 
};

我尝试了一切,但似乎找不到问题,我看到许多人在使用绝对路径时遇到这种问题,但是我的相对路径似乎还不错。 我收到此错误。

WARNING in ./node_modules/@angular/core/fesm5/core.js 17170:15-36
Critical dependency: the request of a dependency is an expression
 @ ./src/main.ts

WARNING in ./node_modules/@angular/core/fesm5/core.js 17182:15-102
Critical dependency: the request of a dependency is an expression
 @ ./src/main.ts

WARNING in ./node_modules/@angular/core/fesm5/core.js 17170:15-36
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
 @ ./src/main.ts 1:0-47 6:4-18

WARNING in ./node_modules/@angular/core/fesm5/core.js 17182:15-102
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
 @ ./src/main.ts 1:0-47 6:4-18

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/app.module' in 'C:\Users\desti\Downloads\toh-pt6\src'
 @ ./src/main.ts 3:0-45 8:41-50

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './environments/environment' in 'C:\Users\desti\Downloads\toh-pt6\src'
 @ ./src/main.ts 4:0-57 5:4-15

0 个答案:

没有答案