Coder Social home page Coder Social logo

yarn start not working about substrate-front-end-template HOT 7 OPEN

 avatar commented on June 30, 2024
yarn start not working

from substrate-front-end-template.

Comments (7)

ltfschoen avatar ltfschoen commented on June 30, 2024 1

The reason you are getting error Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation) is because you are trying to use an old version of Yarn 1.22.15 (see your output of yarn --version) whilst running yarn start, however the repository is configured to use Node.js LTS v16.18.1 (hence why in .nvmrc it has lts/gallium) and to use Yarn 3.1.1 (hence why there's a .yarn folder with .yarn/releases/yarn-3.1.1.cjs and a file called .yarnrc.yml whose contents include the line yarnPath: .yarn/releases/yarn-3.1.1.cjs).

I got the same error when using the node:gallium-alpine pre-built Docker image since it was using Yarn v1 (1.22.19), but the contents of the .yarn folder and .yarnrc.yml file in this repository requires Yarn v3 and was causing a conflict.

I even got an error trying to use the versions used in this repository of Node.js LTS Gallium and Yarn 3.1.1, but when I upgraded to Yarn 3.3.0 it resolved the issue when running yarn start. To do that I first had to:

Use stable Node.js 16.x (i.e. lts/gallium)

Remove the .yarn directory,

rm -rf .yarn

Temporarily backup by renaming .yarnrc.yml since it has some extra lines of code at the top to retain and use later

mv .yarnrc.yml .yarnrc.yml.old

Run the following to create a .yarn folder with latest Yarn v3.3.0 and re-create .yarnrc.yml with Yarn v3.3.0 (with contents yarnPath: .yarn/releases/yarn-3.3.0.cjs)

yarn policies set-version 3.3.0

Copy remainder of .yarnrc.yml.old back into .yarnrc.yml, so the file became:

nodeLinker: node-modules

plugins:
  - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
    spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.3.0.cjs

Then using Node.js with LTS Gallium, I simply followed these Yarn instructions to install its Corepack and the latest Yarn 3.3.0 and also installed Git first since it used that, then after doing that I was able to run yarn start without issue.

Alpine Linux

apk update && apk add --update git && rm -rf /var/cache/apk/*
corepack enable \
    && corepack prepare yarn@stable --activate \
    && yarn set version 3.3.0 \
    && yarn install
yarn start

Note: If you're using Ubuntu rather than Alpine Linux then you'd instead install git with apt-get update && apt-get install -y git.

There's also an inconsistency in the Node.js version used in the repo. The CircleCI .circleci/config.yml file is using Node.js 16.14, whereas the .nvmrc file is using Node.js 16.18 (Gallium) lts/gallium

from substrate-front-end-template.

sbzi1020 avatar sbzi1020 commented on June 30, 2024

@hariaccubits I saw some errors in your yarn install process. You might re-install it again or try to figure out what is that error.

from substrate-front-end-template.

nuke-web3 avatar nuke-web3 commented on June 30, 2024

@ltfschoen - looks like a good stack exchange question and answer about how to use this template to me, and per #245 comment for a PR to update things here, I am sure a succinct a minimal update would be very welcome :)

from substrate-front-end-template.

ltfschoen avatar ltfschoen commented on June 30, 2024

The reason you are getting error Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation) is because you are trying to use an old version of Yarn 1.22.15 (see your output of yarn --version) whilst running yarn start, however the repository is configured to use Node.js LTS v16.18.1 (hence why in .nvmrc it has lts/gallium) and to use Yarn 3.1.1 (hence why there's a .yarn folder with .yarn/releases/yarn-3.1.1.cjs and a file called .yarnrc.yml whose contents include the line yarnPath: .yarn/releases/yarn-3.1.1.cjs).

I got the same error when using the node:gallium-alpine pre-built Docker image since it was using Yarn v1 (1.22.19), but the contents of the .yarn folder and .yarnrc.yml file in this repository requires Yarn v3 and was causing a conflict.

I even got an error trying to use the versions used in this repository of Node.js LTS Gallium and Yarn 3.1.1, but when I upgraded to Yarn 3.3.0 it resolved the issue when running yarn start. To do that I first had to:

Use stable Node.js 16.x (i.e. lts/gallium)

Remove the .yarn directory,

rm -rf .yarn

Temporarily backup by renaming .yarnrc.yml since it has some extra lines of code at the top to retain and use later

mv .yarnrc.yml .yarnrc.yml.old

Run the following to create a .yarn folder with latest Yarn v3.3.0 and re-create .yarnrc.yml with Yarn v3.3.0 (with contents yarnPath: .yarn/releases/yarn-3.3.0.cjs)

yarn policies set-version 3.3.0

Copy remainder of .yarnrc.yml.old back into .yarnrc.yml, so the file became:

nodeLinker: node-modules

plugins:
  - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
    spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.3.0.cjs

Then using Node.js with LTS Gallium, I simply followed these Yarn instructions to install its Corepack and the latest Yarn 3.3.0 and also installed Git first since it used that, then after doing that I was able to run yarn start without issue.

Alpine Linux

apk update && apk add --update git && rm -rf /var/cache/apk/*
corepack enable \
    && corepack prepare yarn@stable --activate \
    && yarn set version 3.3.0 \
    && yarn install
yarn start

Note: If you're using Ubuntu rather than Alpine Linux then you'd instead install git with apt-get update && apt-get install -y git.

There's also an inconsistency in the Node.js version used in the repo. The CircleCI .circleci/config.yml file is using Node.js 16.14, whereas the .nvmrc file is using Node.js 16.18 (Gallium) lts/gallium

my initial post above is erroneous, please refer to this stackexchange post

from substrate-front-end-template.

sacha-l avatar sacha-l commented on June 30, 2024

Thanks for chiming in here @ltfschoen! Just going through these issues and trying to sort them out. Am I good to close this?

from substrate-front-end-template.

ltfschoen avatar ltfschoen commented on June 30, 2024

Maybe revert to using Yarn 1.x instead of Yarn 3.x or update the README with more precise steps on how to configure it to use Yarn 3.x so users don't encounter this issue and give up.

from substrate-front-end-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.