Search code examples
orocommerce

Module not Found "underscore" in Orocommerce (assets:install)


I'm trying the orocommerce 5.1 framework, all is working when you follow the doc but I encounter a problem when i try to install the assets.

It turn back that exception when I do "php bin/console oro:assets:install --env=dev"

  PublicPath: /build/admin/
  assets by status 13.6 MiB [cached] 281 assets

  ERROR in ./bundles/oroui/js/extend/underscore.js
  Module not found: Error: Package path ./underscore is not exported from package /Users/user/VHost/oroTest/node_modules/underscore (see exports field in /Users/user/VHost/oroTest/node_modules/underscore/package.json)
  Did you mean './underscore'?
  Requests that should resolve in the current directory need to start with './'.
  Requests that start with a name are treated as module requests and resolve within module directories (/Users/user/VHost/oroTest/public/build/admin/, /Users/user/VHost/oroTest/public, /Users/user/VHost/oroTest/assets, /Users/user/VHost/oroTest/public/bundles, /Users/user/VHost/oroTest/public/js, /Users/user/VHost/oroTest/node_modules).
  If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
   @ ./bundles/oroui/js/app.js 15:14-35

  admin.oro theme compiled with 1 error in 95717 ms

default theme:
  PublicPath: /build/default/
  assets by status 4.65 MiB [cached] 40 assets

  ERROR in ./bundles/oroui/js/extend/underscore.js
  Module not found: Error: Package path ./underscore is not exported from package /Users/user/VHost/oroTest/node_modules/underscore (see exports field in /Users/user/VHost/oroTest/node_modules/underscore/package.json)
  Did you mean './underscore'?
  Requests that should resolve in the current directory need to start with './'.
  Requests that start with a name are treated as module requests and resolve within module directories (/Users/user/VHost/oroTest/public/build/default/, /Users/user/VHost/oroTest/public, /Users/user/VHost/oroTest/assets, /Users/user/VHost/oroTest/public/bundles, /Users/vincentorru/VHost/oroTest/public/js, /Users/user/VHost/oroTest/node_modules).
  If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
   @ ./bundles/oroui/js/app.js 15:14-35

  default theme compiled with 1 error in 78195 ms

custom theme:
  PublicPath: /build/custom/
  assets by status 4.19 MiB [cached] 35 assets

  ERROR in ./bundles/oroui/js/extend/underscore.js
  Module not found: Error: Package path ./underscore is not exported from package /Users/vincentorru/VHost/oroTest/node_modules/underscore (see exports field in /Users/vincentorru/VHost/oroTest/node_modules/underscore/package.json)
  Did you mean './underscore'?
  Requests that should resolve in the current directory need to start with './'.
  Requests that start with a name are treated as module requests and resolve within module directories (/Users/vincentorru/VHost/oroTest/public/build/custom/, /Users/vincentorru/VHost/oroTest/public, /Users/vincentorru/VHost/oroTest/assets, /Users/vincentorru/VHost/oroTest/public/bundles, /Users/vincentorru/VHost/oroTest/public/js, /Users/vincentorru/VHost/oroTest/node_modules).
  If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
   @ ./bundles/oroui/js/app.js 15:14-35

  custom theme compiled with 1 error in 79959 ms

I have tryed to update the project, reinstall dependencies, set "webpack.config.js" accessible. nothing work for me Thank you for your help :)


Solution

  • After a good night's sleep and attempting to reinstall the app, I discovered why Node was failing.

    My environment use Homebrew on macOS, which by default installs the latest version of npm within the Node package.

    In fact, I was unable to handle it because of the latest version of npm (9.9.2), which was not compatible with the "underscore" library, as the previous logs indicated.

    I use the command npm install -g [email protected] to use explicitly the down version of npm found on package.json "npm": ">=9.3.1 <10"

    I hope that will help you