Skip to content

Commit

Permalink
Add warning for npm and tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
frandiox committed Jul 8, 2024
1 parent 6951cd4 commit 1e6dd1a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/cli/src/commands/hydrogen/setup/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {
flagsToCamelObject,
} from '../../../lib/flags.js';
import Command from '@shopify/cli-kit/node/base-command';
import {renderSuccess, renderTasks} from '@shopify/cli-kit/node/ui';
import {
renderSuccess,
renderTasks,
renderWarning,
} from '@shopify/cli-kit/node/ui';
import {
getPackageManager,
installNodeModules,
Expand Down Expand Up @@ -99,6 +103,8 @@ export async function runSetupCSS({
},
];

let isNpm = false;

if (installDeps && needsInstallDeps) {
const gettingPkgManagerPromise = getPackageManager(
remixConfig.rootDirectory,
Expand All @@ -108,6 +114,8 @@ export async function runSetupCSS({
title: 'Installing new dependencies',
task: async () => {
const packageManager = await gettingPkgManagerPromise;
isNpm = packageManager === 'npm' || packageManager === 'unknown';

await installNodeModules({
directory: remixConfig.rootDirectory,
packageManager,
Expand All @@ -129,4 +137,16 @@ export async function runSetupCSS({
: '') +
`\nFor more information, visit ${CSS_STRATEGY_HELP_URL_MAP[strategy]}`,
});

// Due to a bug in NPM related to optional dependencies in Tailwind,
// we need to reinstall dependencies to fix node_modules:
// https://github.com/npm/cli/issues/4828
if (needsInstallDeps && isNpm && strategy === 'tailwind') {
renderWarning({
body: [
'Due to a bug in NPM, you might need to reinstall dependencies again.\nRun',
{command: 'npm install'},
],
});
}
}

1 comment on commit 1e6dd1a

@Lonzarostore
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dank je wel voor hulp Frans

Please sign in to comment.