Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Couldn't find a package.json file #9011

Closed
666asd opened this issue Nov 14, 2023 · 11 comments
Closed

Error: Couldn't find a package.json file #9011

666asd opened this issue Nov 14, 2023 · 11 comments

Comments

@666asd
Copy link

666asd commented Nov 14, 2023

npm ls -g yarn

npm WARN config global --global, --local are deprecated. Use --location=global instead.
/opt/node/lib
└── [email protected]

yarn --help

Error: Couldn't find a package.json file in "/"
at MessageError.ExtendableBuiltin (/opt/node/lib/node_modules/yarn/lib/cli.js:721:66)
at new MessageError (/opt/node/lib/node_modules/yarn/lib/cli.js:750:123)
at /opt/node/lib/node_modules/yarn/lib/cli.js:41356:15
at Generator.next ()
at step (/opt/node/lib/node_modules/yarn/lib/cli.js:310:30)
at /opt/node/lib/node_modules/yarn/lib/cli.js:321:13

@jrsherry
Copy link

Looks like this was introduced in the release this morning; 1.22.20

@PhilippMeissner
Copy link

Facing the same issues ever since 1.22.20.
We fixed it by currently pinning our version to 1.22.19 via npm install -g [email protected]

@HitLuca
Copy link

HitLuca commented Nov 14, 2023

for us what fixed it was removing a --cwd option

@canderson-activatecare
Copy link

Looks like this was introduced in the release this morning; 1.22.20

Confirming that this has also broken our pipeline due to --cwd flag no longer working. Also will be pinning to 1.22.19 for the time being.

Cyberboss added a commit to tgstation/tgstation-server that referenced this issue Nov 14, 2023
@Cyberboss
Copy link

Here's a repro Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:6.0-bookworm-slim AS build

# install node and npm
# replace shell with bash so we can source files
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.39.1/install.sh | sh

ENV NODE_VERSION 20.5.1

ENV NVM_DIR /root/.nvm
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

RUN . $NVM_DIR/nvm.sh \
    && nvm install $NODE_VERSION \
	&& nvm use $NODE_VERSION \
  && npx --yes yarn add [email protected] [email protected]

Adding @1.22.19 to the yarn spec works fine

Cyberboss added a commit to tgstation/tgstation-server that referenced this issue Nov 14, 2023
@arcanis
Copy link
Member

arcanis commented Nov 14, 2023

I'm investigating. It seems the problem is triggered when calling Yarn through npx, as this fails:

cd $(mktemp -d) && yarn init -y && yarn install && mkdir foo && cd foo && npx yarn install

Whereas this works:

cd $(mktemp -d) && yarn init -y && yarn install && mkdir foo && cd foo && yarn install

@arcanis arcanis pinned this issue Nov 14, 2023
@martvalja
Copy link

martvalja commented Nov 14, 2023

If this helps I'm facing the same issue, commands (Node version v18.16.0, npm version 9.5.1, macOS Sonoma 14.1.1)

        npm install -g yarn
        yarn set version 1

Result in

Error: Couldn't find a package.json file in "/Users/<username>/test"
    at /Users/<username>/test/.yarn/releases/yarn-1.22.20.cjs:43530:15
    at Generator.next (<anonymous>)
    at step (/Users/<username>/test/.yarn/releases/yarn-1.22.20.cjs:310:30)
    at /Users/<username>/test/.yarn/releases/yarn-1.22.20.cjs:321:13

This was fixed by pinning the yarn version to 1.22.19 as mentioned by @PhilippMeissner

@arcanis
Copy link
Member

arcanis commented Nov 14, 2023

I have identified a fix; I'm working on releasing it

@arcanis
Copy link
Member

arcanis commented Nov 14, 2023

I released the 1.22.21 which should have fixed this; can one of you confirm me that it looks good on your side?

@jrsherry
Copy link

I've confirmed this patch resolved my issue.

@martvalja
Copy link

Fixed for me as well, thank you for the prompt fix 👍

@arcanis arcanis closed this as completed Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants