Ionic 3:以“prod”模式构建:找不到模块“。” [英] Ionic 3: Build in “prod” mode: Cannot find module “.”
问题描述
我们有一个很大的 Ionic
应用,我们试图在生产中
模式,因为它几乎准备好了。我们发现的第一个问题是我们在编译时遇到 build
JavaScript
堆内存不足错误,但是我们通过给节点提供更多内存来修复它:
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屋!