thomvaill / log4brains

✍️ Log and publish your architecture decisions (ADR)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sharp is required to build

cabello opened this issue · comments

Bug Report

Description

I tried to run the build command and it failed due to sharp not being found.

Steps to Reproduce

  1. yarn install --dev log4brains
  2. yarn run log4brains init
  3. yarn run log4brains build
❯ yarn run log4brains build
yarn run v1.22.10
$ /Users/user/workspace/work/project/node_modules/.bin/log4brains build
Building Log4brains...
[Next]
[Next]   FATAL  Cannot find module 'sharp'
Require stack:
- /Users/user/workspace/work/project/node_modules/@log4brains/web/node_modules/next/dist/build/index.js
- /Users/user/workspace/work/project/node_modules/@log4brains/web/dist/cli/commands/build.js
- /Users/user/workspace/work/project/node_modules/@log4brains/web/dist/cli/commands/index.js
- /Users/user/workspace/work/project/node_modules/@log4brains/web/dist/cli/cli.js
- /Users/user/workspace/work/project/node_modules/@log4brains/web/dist/cli/index.js
- /Users/user/workspace/work/project/node_modules/@log4brains/web/dist/index.js
- /Users/user/workspace/work/project/node_modules/log4brains/dist/cli.js
- /Users/user/workspace/work/project/node_modules/log4brains/dist/main.js
- /Users/user/workspace/work/project/node_modules/log4brains/dist/log4brains
[Next]
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected Behavior

To build the site successfully.

Context

I did not want to tell all users to globally install the command, so I added it to the project as a dev dependency.

I did not find sharp in the package.json of this project.

After adding sharp with yarn add -dev sharp the project was built correctly.

Environment

  • Log4brains version: 1.22.10
  • Node.js version: v16.3.0
  • OS and its version: macOS 11.4 / Apple Silicon M1
  • Browser information: N/A

Possible Solution

Add sharp to list of dependencies.

Correction, even after adding sharp I cannot build log4brain:

Building Log4brains...
info  - Creating an optimized production build  
[Next]  warn  - Compiled with warnings

[Next]  ../node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

../node_modules/next/dist/next-server/server/load-components.js
Critical dependency: the request of a dependency is an expression

../node_modules/next/dist/next-server/server/require.js
Critical dependency: the request of a dependency is an expression

../node_modules/next/dist/next-server/server/require.js
Critical dependency: the request of a dependency is an expression

../node_modules/next/dist/next-server/server/require.js
Critical dependency: the request of a dependency is an expression

/Users/user/workspace/work/project/node_modules/awilix/lib/container.js
Critical dependency: the request of a dependency is an expression

/Users/user/workspace/work/project/node_modules/awilix/lib/load-module-native.js
Critical dependency: the request of a dependency is an expression
[Next] 
info  - Collecting page data  
info  - Finalizing page optimization  
[Next]  warn  - Statically exporting a Next.js application via `next export` disables API routes.
This command is meant for static-only hosts, and is not necessary to make your application static.
Pages in your application without server-side data dependencies will be automatically statically exported by `next build`, including pages powered by `getStaticProps`.
Learn more: https://err.sh/vercel/next.js/api-routes-static-export
[====] Generating search index... Done

 ✔  Your Log4brains static site was successfully generated to .log4brains/out with a total of 3 ADRs

✨  Done in 21.91s.

I think it has something to do with M1 but according to this comment lovell/sharp#2460 (comment) M1 is now supported by sharp and I am using the latest version 0.29.1.

It's worth mentioning that the preview mode works like a charm, and looks so nice! ❤️

Any updates on this? I'm experiencing the exact same issue. Preview works like a charm, build doesn't. Working on windows 10 with node v16.10.0. Build in Gitlab-CI Pipeline according to tutorial in readme (https://github.com/thomvaill/log4brains#-getting-started) doesn't work properly aswell