Open Osmose opened 9 months ago
Having the same issue with a dependency that has typescript
as a peerOptional
dependency, but it's installed no matter what I try.
Same on Linux. Thought I was losing my mind. And this is not just optional dependences, but none of the dependency types documented under https://bun.sh/docs/runtime/bunfig#package-manager follow those settings. I've tried setting dev and peer to false and are always installed.
Also documented here: https://bun.sh/docs/cli/install#configuration
EDIT: unless I'm misunderstanding how this is expected to work. I can now see that the settings apply to my own project dependencies, but NOT to transitive dependencies (where optional still installed)
For some reason it seems to skip the optional dependencies correctly when I install dependencies as part of a docker build
when I have the dependency's optional dependency as a dev dependency and only install production dependencies though.
This is my Dockerfile:
FROM oven/bun:1.0.26-alpine
ENV CI true
ENV NODE_ENV production
COPY package.json package.json
COPY bun.lockb bun.lockb
RUN bun install --production --frozen-lockfile
When I run a container with that built image the optional dependency is not installed, which is correct. I don't know if it's the NODE_ENV
or CI
env variables that affect it in some way to make it behave correctly...
I am seeing this issue in Bun v1.1.3. I set [install.optional] = false in bunfig.toml, but sharp, an optional dependency of astro, is still installed, which is not expected.
👍
present in 1.1.17
What version of Bun is running?
1.0.13+d8ca6ca69
What platform is your computer?
Darwin 22.5.0 x86_64 i386
What steps can reproduce the bug?
Create a directory with two files:
package.json
bunfig.toml
Then run
bun install
andls node_modules/fsevents
to check iffsevents
(which is an optional dependency forchokidar
) was installed.What is the expected behavior?
node_modules/fsevents
wasn't installed and doesn't exist.What do you see instead?
fsevents
is installed undernode_modules/fsevents
.Additional information
Ran into this while attempting to make a standalone binary with
bun build
that uses chokidar—#3903 prevents this from working sincefsevents
is a native module, so I'd like to avoid installing it since it's an optional dependency to chokidar, but bun seems to install it regardless of mybunfig.toml
,--production
flags, etc.I also checked that it wasn't a cache issue by running
rm -rf ~/.bun/install/cache
, it still installs fsevents.