Strange build error on a computer, but not the other (ERR PACKAGE PATH NOT EXPORTED)

Hi !
This is a message in a bottle, after 4 hours of searching to resolve and just failing…

We work on a Sage10 website on two different computers, node and yarn are strictly in the same versions, files are synchronized with git. Wordpress v5.9.

On my computer (Ubuntu 20.04, as dual- boot on a Dell G15) : everything builds fine, no errors

On my co-worker computer (Ubuntu 20.04, as dual-bootLinux on a Dell XPS15) : an error on build that I can’t understand.

The error message :

(.....)$ yarn build
yarn run v1.22.19
$ bud build
✖  Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './extension/decorators' is not defined by "exports" in [secure]/node_modules/@roots/bud-framework/package.json 
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:429:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:703:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> ([secure]/node_modules/@roots/bud-stylelint/lib/cjs/index.js:23:22)

We tried every solution we found for this type of error (change node version, back to LTS version, erase node_modules folder and .lock files and reinstall everything).
Nothing resolves…

The very strange thing is that we use exactly the same environments (I installed both, from the Linux dual boot to the Sage website)

Has anyone met this problem before or has an idea of its origin ?
Thanks for your kind help !

Ok, our issue is resolved.

If it can helps anyone : here is an explanation.

The problem :

After the initial yarn install, when we add other modules (in our case : installing poppers, stylelint, eslint, prettier, bootstrap, webpack and uninstalling Tailwind) : the package.json file is edited and these modules are automatically added to the array of dependencies.

For every new install, the installation is started with this edited package.json file, despite there is no error during the installation, the build breaks.
Trying to reinstall node_modules, starting from the edited package.json file, fails on every computer.

The solution :

  • replace edited package.json file with the initial file from Roots/sage
  • yarn install + do a complete install of other added modules, as they are not listed in package.json (in our case : installing poppers, stylelint, eslint, prettier, bootstrap, webpack and uninstalling Tailwind)
  • ok, yarn build works :slight_smile: !