oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.83k stars 2.73k forks source link

Bun could not find a package.json file. #5483

Open henriquealbert opened 1 year ago

henriquealbert commented 1 year ago

What version of Bun is running?

1.0.1+31aec4ebe325982fc0ef27498984b0ad9969162b

What platform is your computer?

Darwin 23.0.0 arm64 arm

What steps can reproduce the bug?

Issue while trying to install packages using bun install in Meteor build

Steps to reproduce:

$ meteor build --directory ./dist
$ cd dist/bundle/programs/server
$ bun install

error: MissingPackageJSON
Bun could not find a package.json file.

What is the expected behavior?

It should simply install the npm dependencies.

What do you see instead?

Screenshot 2023-09-15 at 14 04 33

Additional information

I created a repository and added the steps to reproduce the issue: https://github.com/henriquealbert/bun-meteor-build

Elwqnn commented 1 year ago

upupup

L422Y commented 1 year ago

This is occurring for me when using local package sources:

 "devDependencies": {
    "my-package": "file:/Users/larry/Development/oss/my-package"
  }

I've confirmed there is a valid package.json in the my-package directory

Everything works as expected with pnpm and npm

pgmatheus commented 1 year ago

In my case, I've added 'sudo,' and everything worked after.

rafsawicki commented 1 year ago

I actually ran into a similar issue, but with a docker build, where a package.json file was copied with incorrect user permissions. In mine (and I guess @pgmatheus) instance, the bug is more about providing a proper error message - the file exists but is not accessible for bun.

Kitenite commented 12 months ago

I ran into a similar issue, linking by file in package. package.json exist in dependency package. npm install works fine.

  "dependencies": {
          "my-package": "file://Users/path/to/package"
fpigeonjr commented 11 months ago

ran into similar issue with Docker and it was a permission error here is how we solved it:

# Dockerfile

COPY --chown=app:app ./package.json ./bun.lockb /home/app/
garviand commented 11 months ago

Running into this with GitHub actions. I'm not using any file:// dependencies.

kylekirkby commented 11 months ago

My issue was that I was using a Git submodule but hadn't set the submodule up in a fresh clone. We should handle this in a cleaner way. If possible, warn users that the package was missing?

DeniroBlack commented 11 months ago

Command working after installing latest node js 😁

yxlwfds commented 10 months ago

up, ubuntu, snap install bun-js,package.json has created,npm i is ok

yxlwfds commented 10 months ago

image 删除不掉,装不上,用不了,哈哈

Jarred-Sumner commented 10 months ago

if you can use sudo perf trace or strace and report the output, that would help. Seeing what the system call is returning would tell us where the error is

PaulJPhilp commented 10 months ago

I had this problem today. It turns out that I had this entry in my "dependencies" : ".", ".". When I removed that entry, bun started to work again. I don't know how that line got there, perhaps bun put it there at some point?

image

patrickjquinn commented 9 months ago

Piling on here, where I'm pointing a dep at "file://" in the package.json I get the "missing package.json" message. No issue with yarn, npm or pnpm.

alanpog commented 8 months ago

I fixed this by using bun link instead of the file:/ syntax. That seems to be the bun way to handle local deps.

L422Y commented 8 months ago

yep! "bun link" works better than any other solution for me as well

PaulJPhilp commented 8 months ago

Awesome, thanks!

On Thu, Feb 8, 2024 at 7:52 PM Larry Williamson @.***> wrote:

yep! "bun link" works better than any other solution for me as well

— Reply to this email directly, view it on GitHub https://github.com/oven-sh/bun/issues/5483#issuecomment-1935161855, or unsubscribe https://github.com/notifications/unsubscribe-auth/BA6V6ZWS6P2EYAQ3QGIAYJLYSVXM5AVCNFSM6AAAAAA42C3XKKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZVGE3DCOBVGU . You are receiving this because you commented.Message ID: @.***>

CrossScarDev commented 7 months ago

I am trying to install a custom cli and am getting this error when running this command: bun add -g . with this package.json:

{
  "name": "cslang",
  "module": "src/index.ts",
  "type": "module",
  "scripts": {
    "dev": "bun src/index.ts"
  },
  "devDependencies": {
    "@types/bun": "latest"
  },
  "dependencies": {
    "citty": "^0.1.6",
    "consola": "^3.2.3"
  },
  "bin": {
    "cslang": "./src/index.ts"
  }
}
fccjr24 commented 2 months ago

bun link didn't work for me when linking to a separate package in a monorepo

ricardolucena commented 3 weeks ago

Same problem here.

ricardolucena commented 3 weeks ago

ricardo@ricardo:/var/www/html/typebot.io$ bun i error: Bun could not find a package.json file to install from note: Run "bun init" to initialize a project