鍍金池/ 問答/HTML5  HTML/ Ionic3項目可以serve但是build會報錯大概是什么原因?

Ionic3項目可以serve但是build會報錯大概是什么原因?

一個angular-ionic開發(fā)的項目,用ionic serve命令運行沒有任何問題,但是一旦想用ionic build --prod命令打包就開始報錯。這種情況一般都是由于什么原因引起的?有沒有大佬指點一下。

報錯的內(nèi)容:

[09:26:18] ionic-app-script task: "build"
[09:26:18] Error: Encountered undefined provider! Usually this means you have a circular dependencies (might be caused

        by using 'barrel' index.ts files.

Error: Encountered undefined provider! Usually this means you have a circular dependencies (might be caused by using 'barrel' index.ts files.

at syntaxError (E:\abcd\node_modules\@angular\compiler\bundles\compiler.umd.js:1550:34)
at E:\abcd\node_modules\@angular\compiler\bundles\compiler.umd.js:14936:40
at Array.forEach (<anonymous>)
at CompileMetadataResolver._getProvidersMetadata (E:\abcd\node_modules\@angular\compiler\bundles\compiler.umd.js:14921:19)
at CompileMetadataResolver.getNgModuleMetadata (E:\abcd\node_modules\@angular\compiler\bundles\compiler.umd.js:14576:50)
at addNgModule (E:\abcd\node_modules\@angular\compiler\bundles\compiler.umd.js:23050:58)
at E:\abcd\node_modules\@angular\compiler\bundles\compiler.umd.js:23061:14
at Array.forEach (<anonymous>)
at _createNgModules (E:\abcd\node_modules\@angular\compiler\bundles\compiler.umd.js:23060:26)
at analyzeNgModules (E:\abcd\node_modules\@angular\compiler\bundles\compiler.umd.js:22935:14)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ionic-hello-world@0.0.0 ionic:build: ionic-app-scripts build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world@0.0.0 ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

檢查了所有的module,并沒有出現(xiàn)循環(huán)依賴。不過項目在最近改用了Ionic3的懶加載重新弄了路由,不知道是不是和這個有點關系

回答
編輯回答
獨特范

ionic3和2的結構差別還是挺大,單單針對你的這個錯誤,有可能是你的服務和模塊聲明在同一個文件,并且服務優(yōu)先于模塊聲明。

2017年10月3日 00:31
編輯回答
乞許

你的第一個錯誤是,你沒有在app.modules.ts中引入barrel這個provider

2018年8月15日 22:35