Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay 7.1 Angular npmRunBuild - TypeError: Cannot read property 'mai
Hey, I am new to angular and also liferay. I am attempting to integrate an angular project into liferay 7.1 using the liferay-npm-bundler.
I have managed to resolve the hundred or so previous errors so the module is now at a stage where it tries to bundle the 190 dependencies.
I am now receiving this error, I have googled it but cannot find anything on it at all.
Any help much appreciated.
> Task :downloadNode SKIPPED
> Task :modules:angular-npm-portlet:downloadNode SKIPPED
> Task :modules:angular-npm-portlet:expandJSCompileDependencies UP-TO-DATE
> Task :modules:angular-npm-portlet:npmInstall UP-TO-DATE
> Task :modules:angular-npm-portlet:npmRunBuild
> angular-npm-portlet@1.0.0 build C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet
> tsc && liferay-npm-bundler
Bundling 190 dependencies...
TypeError: Cannot read property 'main' of undefined
at loadAsDirectorySync (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\resolve\lib\sync.js:123:21)
at loadNodeModulesSync (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\resolve\lib\sync.js:150:21)
at Function.module.exports [as sync] (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\resolve\lib\sync.js:52:17)
at configRequire (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\config.js:97:37)
at C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\config.js:241:22
at Array.map (<anonymous>)
at instantiatePlugins (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\config.js:233:21)
at Object.getPlugins (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\config.js:224:9)
at C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\index.js:308:48
at new Promise (<anonymous>)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! angular-npm-portlet@1.0.0 build: `tsc && liferay-npm-bundler`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-npm-portlet@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-04-09T15_51_10_748Z-debug.log
> Task :modules:angular-npm-portlet:npmRunBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':modules:angular-npm-portlet:npmRunBuild'.
> Process 'command 'cmd'' finished with non-zero exit value 1
I have managed to resolve the hundred or so previous errors so the module is now at a stage where it tries to bundle the 190 dependencies.
I am now receiving this error, I have googled it but cannot find anything on it at all.
Any help much appreciated.
> Task :downloadNode SKIPPED
> Task :modules:angular-npm-portlet:downloadNode SKIPPED
> Task :modules:angular-npm-portlet:expandJSCompileDependencies UP-TO-DATE
> Task :modules:angular-npm-portlet:npmInstall UP-TO-DATE
> Task :modules:angular-npm-portlet:npmRunBuild
> angular-npm-portlet@1.0.0 build C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet
> tsc && liferay-npm-bundler
Bundling 190 dependencies...
TypeError: Cannot read property 'main' of undefined
at loadAsDirectorySync (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\resolve\lib\sync.js:123:21)
at loadNodeModulesSync (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\resolve\lib\sync.js:150:21)
at Function.module.exports [as sync] (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\resolve\lib\sync.js:52:17)
at configRequire (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\config.js:97:37)
at C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\config.js:241:22
at Array.map (<anonymous>)
at instantiatePlugins (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\config.js:233:21)
at Object.getPlugins (C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\config.js:224:9)
at C:\Users\User\Documents\process-portal\com-company-Project\modules\angular-npm-portlet\node_modules\liferay-npm-bundler\lib\index.js:308:48
at new Promise (<anonymous>)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! angular-npm-portlet@1.0.0 build: `tsc && liferay-npm-bundler`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-npm-portlet@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-04-09T15_51_10_748Z-debug.log
> Task :modules:angular-npm-portlet:npmRunBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':modules:angular-npm-portlet:npmRunBuild'.
> Process 'command 'cmd'' finished with non-zero exit value 1
We faced exactly the same problem, but we found that this must be OS dependent.
On the OSX 10.13.6 and Debian v.9 compilation works.
On CentOS 7 and Ubuntu 10 we get almost identical error:
On the OSX 10.13.6 and Debian v.9 compilation works.
On CentOS 7 and Ubuntu 10 we get almost identical error:
[[b]INFO[/b]] Bundling 18 dependencies...
[[b]INFO[/b]] TypeError: Cannot read property 'main' of undefined
[[b]INFO[/b]] at loadAsDirectorySync (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/resolve/lib/sync.js:123:20)
[[b]INFO[/b]] at loadNodeModulesSync (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/resolve/lib/sync.js:150:21)
[[b]INFO[/b]] at Function.module.exports [as sync] (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/resolve/lib/sync.js:52:17)
[[b]INFO[/b]] at configRequire (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/config/internal/util.js:33:37)
[[b]INFO[/b]] at /home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/config/internal/bundler.js:104:46
[[b]INFO[/b]] at Array.map (<anonymous>)
[[b]INFO[/b]] at instantiatePlugins (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/config/internal/bundler.js:96:21)
[[b]INFO[/b]] at Object.getPlugins (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/config/internal/bundler.js:79:9)
[[b]INFO[/b]] at /home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/index.js:267:55
[[b]INFO[/b]] at <anonymous>
[[b]ERROR[/b]] npm ERR! code ELIFECYCLE
[[b]ERROR[/b]] npm ERR! errno 1
[[b]ERROR[/b]] npm ERR! my-npm-angular-portlet@1.0.0 build: `tsc && liferay-npm-bundler`
[[b]ERROR[/b]] npm ERR! Exit status 1
[[b]ERROR[/b]] npm ERR!
[[b]ERROR[/b]] npm ERR! Failed at the my-npm-angular-portlet@1.0.0 build script.
[[b]ERROR[/b]] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
</anonymous></anonymous>
Jacek BorowiecWe faced exactly the same problem, but we found that this must be OS dependent.
On the OSX 10.13.6 and Debian v.9 compilation works.
On CentOS 7 and Ubuntu 10 we get almost identical error:[[b]INFO[/b]] Bundling 18 dependencies... [[b]INFO[/b]] TypeError: Cannot read property 'main' of undefined [[b]INFO[/b]] at loadAsDirectorySync (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/resolve/lib/sync.js:123:20) [[b]INFO[/b]] at loadNodeModulesSync (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/resolve/lib/sync.js:150:21) [[b]INFO[/b]] at Function.module.exports [as sync] (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/resolve/lib/sync.js:52:17) [[b]INFO[/b]] at configRequire (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/config/internal/util.js:33:37) [[b]INFO[/b]] at /home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/config/internal/bundler.js:104:46 [[b]INFO[/b]] at Array.map (<anonymous>) [[b]INFO[/b]] at instantiatePlugins (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/config/internal/bundler.js:96:21) [[b]INFO[/b]] at Object.getPlugins (/home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/config/internal/bundler.js:79:9) [[b]INFO[/b]] at /home/jacekb/src/angular/my-npm-angular-portlet/node_modules/liferay-npm-bundler/lib/index.js:267:55 [[b]INFO[/b]] at <anonymous> [[b]ERROR[/b]] npm ERR! code ELIFECYCLE [[b]ERROR[/b]] npm ERR! errno 1 [[b]ERROR[/b]] npm ERR! my-npm-angular-portlet@1.0.0 build: `tsc && liferay-npm-bundler` [[b]ERROR[/b]] npm ERR! Exit status 1 [[b]ERROR[/b]] npm ERR! [[b]ERROR[/b]] npm ERR! Failed at the my-npm-angular-portlet@1.0.0 build script. [[b]ERROR[/b]] npm ERR! This is probably not a problem with npm. There is likely additional logging output above. </anonymous></anonymous>
Yes this is exactly the same error pretty much. I have Windows 10 Pro. Thanks for getting in touch. Not quite sure where to go from this
Apparently the bundler is failing when trying to instantiate a plugin. This is the source code that is failing:
https://github.com/liferay/liferay-npm-build-tools/blob/7d01c884866c9dd4bcd70d2cd15dc2e9b1fa855f/packages/liferay-npm-bundler/src/config/internal/bundler.js#L89
Can you see if there's something wrong in your .npmbundlerrc file? Otherwise I would advise to create an issue in https://github.com/liferay/liferay-npm-build-tools/issues and upload a zipped sample project to be able to reproduce it.
Thanks.
https://github.com/liferay/liferay-npm-build-tools/blob/7d01c884866c9dd4bcd70d2cd15dc2e9b1fa855f/packages/liferay-npm-bundler/src/config/internal/bundler.js#L89
Can you see if there's something wrong in your .npmbundlerrc file? Otherwise I would advise to create an issue in https://github.com/liferay/liferay-npm-build-tools/issues and upload a zipped sample project to be able to reproduce it.
Thanks.
Thanks for the reply Ivan.
My .npmbundlerrc file is empty json such as in the example found in the below link.
https://github.com/liferay/liferay-blade-samples/blob/7.1/gradle/apps/npm/angular-npm-portlet/.npmbundlerrc
This compiles for the example angular project found in the link and also compiles for me locally when I run that module with my local instance of liferay 7.1
So that suggests to me that it is a problem with my module set up some how breaking the bundling component.
I can go ahead and upload the code into an issue if that is what you suggest?
My .npmbundlerrc file is empty json such as in the example found in the below link.
https://github.com/liferay/liferay-blade-samples/blob/7.1/gradle/apps/npm/angular-npm-portlet/.npmbundlerrc
This compiles for the example angular project found in the link and also compiles for me locally when I run that module with my local instance of liferay 7.1
So that suggests to me that it is a problem with my module set up some how breaking the bundling component.
I can go ahead and upload the code into an issue if that is what you suggest?
I ran a npm audit fix on the module.
During this parts of the package.json file were updated to newer versions, I am guessing that the key difference is the liferay-npm-bundler got updated from 2.0.0 to 2.7.1
After this upgrade the error has gone away and the files are bundled so this issue can be closed.
Thanks for the comments
During this parts of the package.json file were updated to newer versions, I am guessing that the key difference is the liferay-npm-bundler got updated from 2.0.0 to 2.7.1
After this upgrade the error has gone away and the files are bundled so this issue can be closed.
Thanks for the comments

Good to hear that.
However, 2.7.1 is a canary release, as you can see in the versions tab of https://www.npmjs.com/package/liferay-npm-bundler
I'm not saying that you can't use it because we are already using it too, but keep in mind that the latest stable is 2.6.2, in case you see any strange behaviour.
However, 2.7.1 is a canary release, as you can see in the versions tab of https://www.npmjs.com/package/liferay-npm-bundler
I'm not saying that you can't use it because we are already using it too, but keep in mind that the latest stable is 2.6.2, in case you see any strange behaviour.
Ivan ZaeraGood to hear that.
However, 2.7.1 is a canary release, as you can see in the versions tab of https://www.npmjs.com/package/liferay-npm-bundler
I'm not saying that you can't use it because we are already using it too, but keep in mind that the latest stable is 2.6.2, in case you see any strange behaviour.
Thanks Ivan,
I have since tried version 2.6.2 however it fails to bundle in that version.
So something changed in version 2.7.1 to make it work for me.
Thanks
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™