WalletConnect / create-eth-app

Create Ethereum-powered apps with one command
https://www.npmjs.com/package/create-eth-app
MIT License
2.75k stars 503 forks source link

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

Open Dentrax opened 2 years ago

Dentrax commented 2 years ago

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:

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

natebolam commented 2 years ago

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

ashishmahawal commented 2 years ago

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

PaulRBerg commented 2 years ago

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!

kokokenada commented 2 years ago

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

Praiz001 commented 2 years ago

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

adam-coster commented 1 year ago

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.

✅ 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 commented 1 year ago

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:

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'
waldemarennsaed commented 2 months ago

To me this whole topic is still unresolved. As @adam-coster has mentioned, the docs explicitly say that .yarn/install-state.gz should be .gitignored.

In my case, my CI-job fails if there is no node_modules directory available - which is the default PnP behavior. Only getting this fixed when adding the nodeLinker: node-modules setting in my .yarnrc.yml config, which leads to the node_modules directory to be created.

I'd rather like to not have the node_modules directory but then my CI job fails with this mentioned error.

waldemarennsaed commented 2 months ago

I found a solution for myself:

According to this article: https://yarnpkg.com/features/caching#zero-installs

When using the PnP (Plug and Play) feature in addition to the offline mirror, the node_modules directory won't be created unless configured via nodeLinker config.

Within my CI setup, I was caching the .yarn directory (with it's .yarn/cache directory, since my enableGlobalCache config is set to false) but I was not caching the .pnp.cjs and .pnp.loader.mjs files.

These files resolve package files without the need for going into the network and fetching the packages from e.g. the npm registry -> therefore the name zero install.

These files, .pnp.cjs and .pnp.loader.mjs are being generated automatically. While running yarn install in my CI job, these files will be created. Adding them to my CI cache allowed these files to exist in the build job.

Lesson learned. Please check if your .pnp.cjs and .pnp.loader.mjs files are being created @Dentrax .

Let me know if you have further insights into your issue. @adam-coster maybe that also fixes your issue?

dylviz commented 2 months ago

Adding them to my CI cache allowed these files to exist in the build job

I don't seem to be caching anything during build. I don't have cache/ inside ./yarn

waldemarennsaed commented 2 months ago

Adding them to my CI cache allowed these files to exist in the build job

I don't seem to be caching anything during build. I don't have cache/ inside ./yarn

If you don't have .yarn/cache that is probably because you don't have:

enableGlobalCache: false

set in your .yarnrc.yml file. That might be useful if you are planning to use it in your CI jobs. You can try it out locally: