create-eth-app icon indicating copy to clipboard operation
create-eth-app copied to clipboard

Failing build on fresh install: "package.json doesn't seem to have been installed"

Open Dentrax opened this issue 3 years ago • 11 comments

Bug Description Yarn throws the following error on fresh install:

The project in /Users/furkan/src/create-eth-app/package.json doesn't seem to have been installed - running an install there might help

What I've tried so far:

  • npm cache clean
  • rm -rf node_modules
  • yarn install (exits 0)
  • Deleting the yarn cache and running yarn install

Steps to Reproduce

  1. yarn create eth-app my-eth-app
  2. Expect error
$ yarn create eth-app my-eth-app

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done in 0s 84ms


Creating a new Ethereum-powered React app in /Users/furkan/src/create-eth-app/my-eth-app.

Downloading template files. This might take a moment.

Installing packages. This might take a couple of minutes.

Usage Error: The project in /Users/furkan/src/create-eth-app/package.json doesn't seem to have been installed - running an install there might help

$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds] [--mode #0]

Aborting installation.
  yarnpkg install --cwd /Users/furkan/src/create-eth-app/my-eth-app has failed.

Expected Behavior It should build?

Additional Context Add any other context about the problem here (screenshots, whether the bug only occurs only in certain mobile/desktop/browser environments, etc.)

OS: macOS 12.1 (Intel) yarn: 3.1.0 node: 17.3.1 npm: 8.3.0 commit: 89a9f219f210dde636e076fd2daa5882671e012b terminal: iTerm2 3.4.14 user: no permission issues

Dentrax avatar Jan 17 '22 21:01 Dentrax

I ma having the exact same issue: OS: macOS 12.2.1 (M1) node: 16.14.0 npm: 8.5.3 commit: 89a9f219f21

natebolam avatar Mar 07 '22 21:03 natebolam

hitting same issue I ma having the exact same issue: OS: macOS 12.2.1 (M1) node: 16.14.0 npm: 8.5.3

ashishmahawal avatar Mar 18 '22 14:03 ashishmahawal

Thanks everyone for reporting! Unfortunately I have never ever managed to reproduce this issue, even if I have very similar environments as you guys do.

Some help would be appreciated here. PRs welcome!

PaulRBerg avatar Mar 18 '22 16:03 PaulRBerg

try touch yarn.lock as a work around https://github.com/yarnpkg/berry/issues/625

kokokenada avatar Apr 28 '22 15:04 kokokenada

I am having exact same error right now on Windows. Any fix yet ?

Praiz001 avatar May 06 '22 12:05 Praiz001

I just ran into this on AWS CodeBuild (for CI), so it was also on a fresh install of everything. I cannot replicate it locally.

EDIT: I was able to replicate it locally by deleting all node_modules folders, .yarn/cache, and .yarn/install-state.gz.

  • Affected yarn v3.2.x and v3.3.1 (I had tried updating to resolve the issue, since that fixed it for someone else, to no avail).
  • The error message was for my root project.json, whose folder was also the working directory.
  • I got the error when I ran yarn node --version (which works locally for me)
  • I got the error when I ran any package.json script. In my case, the command was yarn ci:install
  • There was a yarn.lock file already, so that was not the problem.
  • I listed the files in all parent directories, all the way to /, and there were no package.json, yarn.lock, or other node/npm/yarn-related files in any parent.

✅ I resolved the issue by directly running my commands, instead of doing it through a package.json script.

Previously I had something like:

    // ...
    "scripts": {
        "ci:install":  "yarn workspaces focus root @myScope/package1 @myScope/package2"
    }
    // ...

And I was running the command yarn ci:install on the server. This caused the error to be thrown. By directly running the command yarn workspaces focus root @myScope/package1 @myScope/package2 I was able to avoid the error.

adam-coster avatar Jan 12 '23 19:01 adam-coster

To add onto my prior comment, I was able to confirm that the issue is:

When .yarn/install-state.gz is missing, yarn run ... fails and throws the error initially described in this issue.

This can be resolved by directly doing some sort of an install, without going through a package.json script. For example, yarn install for an entire repo or yarn workspaces focus ... for a subset of packages. Once any kind of install is directly run, the .yarn/install-state.gz file appears and future yarn run calls work as expected.

Note that the docs say that .yarn/install-state.gz should be gitignored, so this is presumably an unintended behavior.

My environment info:

  • Ubuntu 20 (via WSL2 on Windows 11)
  • Node 18.12.1
  • yarn 3.3.1 (via corepack)
  • Monorepo context

Relevant parts of my .yarnrc.yml:

nodeLinker: pnpm
plugins:
  - path: .yarn/plugins/@yarnpkg/plugin-version.cjs
    spec: '@yarnpkg/plugin-version'
  - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
    spec: '@yarnpkg/plugin-workspace-tools'

adam-coster avatar Jan 12 '23 20:01 adam-coster