简体   繁体   English

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

[英]Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in

I know that the question related to the Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in... has been asked many times here. 我知道有关Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in...的问题Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in...已被多次询问。 But, I think it is quiet interesting situation here that I am trying to describe below: 但是,我认为这是一个安静有趣的情况,我想在下面描述:

I having node installed on 2 machines running Ubuntu 16.10 and Ubuntu 17.04. 我在运行Ubuntu 16.10和Ubuntu 17.04的2台机器上安装了节点。

1. On ubuntu 16.04 1.在ubuntu 16.04上

Node is installed through these command lines: 通过以下命令行安装节点:

sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install nodejs

2. On ubuntu 17.04 2.在ubuntu 17.04上

Ubuntu 17.04 is already with a new version of node. Ubuntu 17.04已经有了新版本的节点。 The installation is done through 安装完成

sudo apt-get install nodejs

3. What is in common between the 2 machines? 3.两台机器有什么共同之处?

3.1. 3.1。 The version of node and npm are: node和npm的版本是:

node -v
# v7.10.0

npm -v
# 4.2.0

3.2. 3.2。 The angular4 application is created through @angular/cli angular4应用程序是通过@ angular / cli创建的

sudo npm install -g @angular/cli
ng new my-app

3.3. 3.3。 A repo on githbub for the angular4 application with docker githbub上的repo用于带有docker的angular4应用程序

The both machine are using the same repo angular4-on-nginx-with-docker 这两台机器都使用相同的repo angular4-on-nginx-docker

4. What is the difference??? 4.有什么区别???

4.1. 4.1。 On Ubuntu 16.10 在Ubuntu 16.10上

$ ng build --prod 

Hash: 64b40519b4565aa62e0b                                                              
Time: 10106ms
chunk    {0} polyfills.71b130084c52939ca448.bundle.js (polyfills) 177 kB {4} [initial] [rendered]
chunk    {1} main.e81f19d3f6b27a436c79.bundle.js (main) 1.09 kB {3} [initial] [rendered]
chunk    {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk    {3} vendor.f7457d5ac1e9743fd76f.bundle.js (vendor) 849 kB [initial] [rendered]
chunk    {4} inline.18e445e37a0efd4dcfa2.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/amine/DockerProjects/tt/nginx/frontend/src'
 @ ./src/main.ts 3:0-74
 @ multi ./src/main.ts

PS: ./src/main.ts is: PS: ./src/main.ts是:

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);

4.2. 4.2。 On Ubuntu 17.04 在Ubuntu 17.04上

$ ng build --prod 
Hash: ab00cb280399614d6ea9                                                              
Time: 16640ms
chunk    {0} polyfills.71b130084c52939ca448.bundle.js (polyfills) 177 kB {4} [initial] [rendered]
chunk    {1} main.97abdc47ac3699c01fa5.bundle.js (main) 5.27 kB {3} [initial] [rendered]
chunk    {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk    {3} vendor.0a8aa978ae08e1954b1c.bundle.js (vendor) 1.89 MB [initial] [rendered]
chunk    {4} inline.3da3f5efaa0601772495.bundle.js (inline) 0 bytes [entry] [rendered]

5. Question 5.问题

Codes in both machines are the same! 两台机器的代码都是一样的! Just a git clone command line is used to get the code. 只需一个git clone命令行来获取代码。 So, what is the difference that make compilation with AOT working on a machine and failing in another machine??? 那么,使用AOT在机器上进行编译并在另一台机器上出现故障会有什么不同?

Thanks,,, 谢谢,,,

The use of "enhanced-resolve":"3.3.0" is a solution for an older version of "@angular/cli" such as "1.2.3" . 使用"enhanced-resolve":"3.3.0"是旧版"@angular/cli"的解决方案,例如"1.2.3"

Another solution, use "@angular/cli": "1.2.6" 另一个解决方案,使用"@angular/cli": "1.2.6"

Use ng build --env=prod instead of ng build --prod . 使用ng build --env=prod而不是ng build --prod When I made a brand new project and ran ng build --prod , I got Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' error. 当我创建一个全新的项目并运行ng build --prod ,我Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'错误。 But when I ran ng build --env=prod dist was generated fine. 但是,当我运行ng build --env=prod dist生成正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到模块:错误:无法解析$$ _ gendir \\ app \\ item-receive-return.module.ngfactory.ts' - Module not found: Error: Can't resolve $$_gendir\app\item-receive-return.module.ngfactory.ts' ./ClientApp/boot.server.ts中的错误找不到模块:错误:无法解析'./../$$_gendir/ClientApp/app/app.app.server.module.ngfactory' - ERROR in ./ClientApp/boot.server.ts Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.server.module.ngfactory' @ ngtools / webpack:缺少app.module.ngfactory - @ngtools/webpack: missing app.module.ngfactory 找不到Angular2 / 4模块:错误:无法解析“ .. \\ app”中的“三个”在解析“ .. \\ app”中的“三个” - Angular2/4 Module not found: Error: Can't resolve 'three' in '..\app' resolve 'three' in '..\app' 未找到 ./src/App.jsx 模块中的错误:错误:无法解析“./component/Footer” - ERROR in ./src/App.jsx Module not found: Error: Can't resolve './component/Footer' npm run build 返回模块未找到:错误:无法在我的 NuxtJS 应用程序中的 docker 容器中解析 - npm run build returns Module not found: Error: Can't resolve in my docker container in my NuxtJS app 将Postgres与新创建的React应用程序一起使用时出错:找不到模块:无法解析“ dns” - Error using Postgres with a newly created React app: Module not found: Can't resolve 'dns' 找不到模块:错误:无法解析“/node_modules/dotenv/lib”中的“fs”-创建反应应用程序 - Module not found: Error: Can't resolve 'fs' in '/node_modules/dotenv/lib' - create react app 找不到模块:错误:无法解析“加密” - Module not found: Error: Can't resolve 'crypto' in 找不到模块:错误:无法解析“加密” - Module not found: Error: Can't resolve 'crypto'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM