Gatsby theme yarn workspaces

153 views Asked by At

May you help me with an error in Gatsby? When I use yarn workspaces to start the development of theme, I get an error while installing the Gatsby dependency on my workspace. Look this.

error C:\Users\Kirito\Desktop\ninja-react\node_modules\gatsby-cli: Command failed.
Exit code: 1
Command: node scripts/postinstall.js
Arguments:
Directory: C:\Users\Kirito\Desktop\ninja-react\node_modules\gatsby-cli
Output:
internal/modules/cjs/loader.js:311
      throw err;

Error: Cannot find module 'project_folder\node_modules\chalk\source'.

My env: Node 14.15.0 - Yarn 1.22.11.

My package json in root:

{
  "workspaces": [
    "sites/theme-dev",
    "packages/gatsby-theme-docs"
  ],
  "private": true
}

I accomplished to install react and react-dom normally, but with Gatsby have a conflict.

{
  "name": "theme-dev",
  "version": "1.0.0",
  "license": "MIT",
  "main": "index.js",
  "private": true,
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}
1

There are 1 answers

0
Ferran Buireu On

According to this GitHub thread try:

  1. Install manually the needed dependencies by:
    npm install chalk
    npm install each-async
    npm install indent-string
    
  2. Upgrade your Node version, remove your node_modules and reinstall all dependencies again.

Remember to clean cache in each trial by running gatsby clean command.

Other interesting threads: