Ionic 3:在“prod"模式下构建:找不到模块“." [英] Ionic 3: Build in “prod” mode: Cannot find module “.”

查看:32
本文介绍了Ionic 3:在“prod"模式下构建:找不到模块“."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个大型 Ionic 应用程序,我们正尝试在 production 模式下build,因为它几乎准备好了.我们发现的第一个问题是编译时出现JavaScript heap out of memory"错误,但我们通过为节点提供更多内存来修复它:

we have a large Ionic app that we’re trying to build in production mode since it’s almost ready. The first issue we found is that we were getting a "JavaScript heap out of memory" error when compiling, but we fixed it by giving more memory to node:

"ionic:build": "node --max-old-space-size=16384 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build",

npm run ionic:build -- --prod

使用此命令成功构建应用程序,但如果我打开它,我会收到以下错误:

With this command the app successfully builds, but if I open it I get the following error:

Uncaught Error: Cannot find module "."
at vendor.js:1
at vendor.js:1
at Object. (vendor.js:1)
at e (vendor.js:1)
at Object. (main.js:1)
at e (vendor.js:1)
at window.webpackJsonp (vendor.js:1)
at main.js:1

我搜索了一下,我发现它可能是由 require 引起的,但我们没有使用它.知道会发生什么或我们可以做些什么来调试问题吗?有没有办法在不缩小 JS 的情况下使用--prod"?

I searched a bit and I found that it could be caused by require, but we aren’t using it. Any idea of what could be going on or what we can do to debug the issue? Is there any way to use "–-prod" without minifying the JS?

这是我的环境:

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:

cordova (Cordova CLI) : 6.5.0 
Gulp CLI              : [09:06:54] CLI version 3.9.1 [09:06:54] Local version 3.9.1
local packages:

@ionic/app-scripts : 3.1.9
Cordova Platforms  : android 6.1.2 ios 4.3.1
Ionic Framework    : ionic-angular 3.9.2
System:

Android SDK Tools : 25.2.5
ios-deploy        : 1.9.1 
ios-sim           : 5.0.8 
Node              : v8.6.0
npm               : 5.3.0 
OS                : macOS High Sierra
Xcode             : Xcode 9.3.1 Build version 9E501 
Misc:

backend : legacy

谢谢!

推荐答案

我发现了问题.在我使用的 package.json 中:

I found the problem. In my package.json I was using:

"typescript": "^2.9.1",

将版本降低到 ~2.6.2 为我修复了它.

Decreasing the version to ~2.6.2 fixed it for me.

这篇关于Ionic 3:在“prod"模式下构建:找不到模块“."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆