skeleton: Javascript setup is not compatible with npm 7 / 8 / 9

The javascript setup in the assets/admin folder uses the file:... syntax to require Sulu packages such as the sulu-admin-bundle: https://github.com/sulu/skeleton/blob/c9640ee7dae09f09a84d83fce0b5143d52fc4a84/assets/admin/package.json#L15-L28

Dependencies that are required like this will be symlinked into the assets/admin/node_moules directory. Unfortunately, npm v7 does not install the dependencies of these dependencies at the moment: https://github.com/npm/cli/issues/2339

Because of this, the dependencies of the Sulu bundles are not installed and the build fails with a lot of error messages like this:

ERROR in /sulu-skeleton/vendor/sulu/sulu/src/Sulu/Bundle/AdminBundle/Resources/js/components/Tabs/Tabs.js
Module not found: Error: Can't resolve 'classnames' in '/sulu-skeleton/vendor/sulu/sulu/src/Sulu/Bundle/AdminBundle/Resources/js/components/Tabs'
 @ /sulu-skeleton/vendor/sulu/sulu/src/Sulu/Bundle/AdminBundle/Resources/js/components/Tabs/Tabs.js 54:0-36 347:22-32
 @ /sulu-skeleton/vendor/sulu/sulu/src/Sulu/Bundle/AdminBundle/Resources/js/components/Tabs/index.js
 @ /sulu-skeleton/vendor/sulu/sulu/src/Sulu/Bundle/AdminBundle/Resources/js/components/index.js
 @ /sulu-skeleton/vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Resources/js/components/ContactDetails/Phone.js
 @ /sulu-skeleton/vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Resources/js/index.js
 @ ./index.js

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 28 (19 by maintainers)

Commits related to this issue

Most upvoted comments

With the merge of #235 and sulu/sulu#7286 we can finally close this issue. Support for newer versions of npm and support of pnpm and bun will be part of Sulu 2.6. Yarn (all versions yeah they really already have 4) are not supported because how they handle local dependencies. Here the current full list which are supported by the admin build:

  • npm
    • ❌ <= 7
    • ✅ 8, 9, 10
  • pnpm
    • ⚠️ <= 7 not tested
    • ✅ 8
  • bun
    • ✅ 1
  • yarn
    • ❌ 1, 2, 3, 4

This only effects the admin build, for the website / your own CSS build you are still free to use which version and package manager you want to use.

@simontol The build with bun is only part of sulu/sulu 2.6@dev yet.

I did test a little bit with bun as an alternative to npm, yarn, pnpm currently bun can be used with any node or npm version to build sulu as it is its own binary. What is required in that case is to run preinstall manually. The linked issue on bun is this one https://github.com/oven-sh/bun/issues/4914.

But when run:

bun run preinstall
bun install

bun run build

If bun will adopt in future some of the npm dependencies behaviour I’m not sure but atleast currently from verison 1.0.0->1.0.13 it works like expected.

Any timeline when this will be updated?

With Node 14 I still have to use the old install script from https://github.com/nodesource/distributions. Which now even prompts with an annoying timeout of 60 seconds to make me aware of having to upgrade.

Sadly custom build still don’t work under npm 7/8. The related issue https://github.com/npm/cli/issues/2339 still exists.