Skip to content

Commit 947fe4d

Browse files
authored
Fix for error on Windows that SHARP_IGNORE_GLOBAL_LIBVIPS is not reco… (#219)
* Fix for error on Windows that SHARP_IGNORE_GLOBAL_LIBVIPS is not recognized as n internal or external command.
1 parent 5c51d39 commit 947fe4d

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

packages/open-next/src/build.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,29 @@ function createImageOptimizationBundle() {
319319
// Sharp provides pre-build binaries for all platforms. https://github.com/lovell/sharp/blob/main/docs/install.md#cross-platform
320320
// Target should be same as used by Lambda, see https://github.com/sst/sst/blob/ca6f763fdfddd099ce2260202d0ce48c72e211ea/packages/sst/src/constructs/NextjsSite.ts#L114
321321
// For SHARP_IGNORE_GLOBAL_LIBVIPS see: https://github.com/lovell/sharp/blob/main/docs/install.md#aws-lambda
322-
cp.execSync(
323-
`SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=arm64 --platform=linux --target=18 --libc=glibc --prefix=${path.resolve(
324-
outputPath,
325-
326-
{
327-
stdio: "inherit",
328-
cwd: appPath,
329-
},
330-
);
322+
323+
//check if we are running in Windows environment then set env variables accordingly.
324+
if (process.platform === "win32") {
325+
cp.execSync(
326+
`set SHARP_IGNORE_GLOBAL_LIBVIPS=1 && npm install --arch=arm64 --platform=linux --target=18 --libc=glibc --prefix=${path.resolve(
327+
outputPath,
328+
329+
{
330+
stdio: "inherit",
331+
cwd: appPath,
332+
},
333+
);
334+
} else {
335+
cp.execSync(
336+
`SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=arm64 --platform=linux --target=18 --libc=glibc --prefix=${path.resolve(
337+
outputPath,
338+
339+
{
340+
stdio: "inherit",
341+
cwd: appPath,
342+
},
343+
);
344+
}
331345
}
332346

333347
function createStaticAssets() {

0 commit comments

Comments
 (0)