Search code examples
strapinext.js13

Dependency install errors while installing Strapi in Next.js app


I’m new to Strapi and this is my first time using it. I need to add its CMS to my Next.js application.

I’ve tried installing Strapi over and over again using npx create-strapi-app backend but every single time I try I get the same error. I’ve uninstalled and reinstalled npm, node and esbuild, trying different versions, but still, nothing works, and I get the same error all the time.

Heres the error/response I get:

PS G:\Workspace\Chris-Ogbuehis-Monorepo\FiftyFiftyFunding\fiftyfiftyfunding> npx create-strapi-app backend
? Choose your installation type Quickstart
(recommended)
You are running Node.js 19.9.0
Strapi only supports LTS versions of Node.js, other versions may not be compatible.
Creating a quickstart project.
Creating a new Strapi application at G:\Workspace\Chris-Ogbuehis-Monorepo\FiftyFiftyFunding\fiftyfiftyfunding\backend.
Creating files.
Error while installing dependencies:
npm WARN config production Use `--omit=dev` instead.
npm WARN config optional Use `--omit=optional` to exclude optional dependencies, or
npm WARN config `--include=optional` to include them.
npm WARN config
npm WARN config     Default value does install optional deps unless otherwise omitted.
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated mailcomposer@3.12.0: This project is unmaintained
npm WARN deprecated @koa/router@10.1.1: **IMPORTANT 10x+ PERFORMANCE UPGRADE**: Please upgrade to v12.0.1+ as we have fixed an issue with debuglog causing 10x slower router benchmark performance, see https://github.com/koajs/router/pull/173
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated   
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated formidable@1.2.6: Please upgrade to latest, formidable@v2 or formidable@v3!
npm WARN deprecated buildmail@3.10.0: This project is unmaintained
npm WARN cleanup Failed to remove some directories [  
npm WARN cleanup   [
npm WARN cleanup     'G:\\Workspace\\Chris-Ogbuehis-Monorepo\\FiftyFiftyFunding\\fiftyfiftyfunding\\backend\\node_modules\\@strapi',
npm WARN cleanup     [Error: EPERM: operation not permitted, rmdir 'G:\Workspace\Chris-Ogbuehis-Monorepo\FiftyFiftyFunding\fiftyfiftyfunding\backend\node_modules\@strapi\admin\ee\admin\pages\SettingsPage'] {
npm WARN cleanup       errno: -4048,
npm WARN cleanup       code: 'EPERM',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'G:\\Workspace\\Chris-Ogbuehis-Monorepo\\FiftyFiftyFunding\\fiftyfiftyfunding\\backend\\node_modules\\@strapi\\admin\\ee\\admin\\pages\\SettingsPage'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path G:\Workspace\Chris-Ogbuehis-Monorepo\FiftyFiftyFunding\fiftyfiftyfunding\backend\node_modules\esbuild-loader\node_modules\esbuild
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js
npm ERR! G:\Workspace\Chris-Ogbuehis-Monorepo\FiftyFiftyFunding\fiftyfiftyfunding\backend\node_modules\esbuild-loader\node_modules\esbuild\install.js:130
npm ERR!     throw new Error(`Expected ${JSON.stringify("0.16.17")} but got ${JSON.stringify(stdout)}`);    
npm ERR!           ^
npm ERR!
npm ERR! Error: Expected "0.16.17" but got "0.19.2"   
npm ERR!     at validateBinaryVersion (G:\Workspace\Chris-Ogbuehis-Monorepo\FiftyFiftyFunding\fiftyfiftyfunding\backend\node_modules\esbuild-loader\node_modules\esbuild\install.js:130:11)
npm ERR!     at G:\Workspace\Chris-Ogbuehis-Monorepo\FiftyFiftyFunding\fiftyfiftyfunding\backend\node_modules\esbuild-loader\node_modules\esbuild\install.js:281:5
npm ERR!
npm ERR! Node.js v19.9.0

npm ERR! A complete log of this run can be found in: C:\Users\Jojo\AppData\Local\npm-cache\_logs\2023-10-31T18_46_16_957Z-debug-0.log
TypeError: Cannot read properties of undefined (reading 'addBreadcrumb')
    at C:\Users\Jojo\AppData\Local\npm-cache\_npx\f5b733dbc92df62b\node_modules\@strapi\generate-new\dist\utils\usage.js:36:31
    at Array.forEach (<anonymous>)
    at Module.captureStderr (C:\Users\Jojo\AppData\Local\npm-cache\_npx\f5b733dbc92df62b\node_modules\@strapi\generate-new\dist\utils\usage.js:35:37)
    at createProject (C:\Users\Jojo\AppData\Local\npm-cache\_npx\f5b733dbc92df62b\node_modules\@strapi\generate-new\dist\create-project.js:133:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async createQuickStartProject (C:\Users\Jojo\AppData\Local\npm-cache\_npx\f5b733dbc92df62b\node_modules\@strapi\generate-new\dist\create-quickstart-project.js:18:3)
PS G:\Workspace\Chris-Ogbuehis-Monorepo\FiftyFiftyFunding\fiftyfiftyfunding>

How can I resolve this?


Solution

  • Personally I find using Node on a host machine to be unreliable - I'd much rather use one in a container so it is easy to wipe and start again. In my view, this is easier than using Node version switching tools. On top of that, I would not have much faith that running these commands in the Windows PowerShell console is going to work - they are always going to be better tested on *nix-like environments.

    I just pulled Node 18 in Docker (in a Linux host) and ran your command successfully. If you can install Docker in your Windows environment then I suspect this will work much more easily. If you can't (or would rather not) use Docker then I would suggest WSL instead.

    For reference here is the console log for using Docker:

    mint # docker pull node:18-slim
    18-slim: Pulling from library/node
    578acb154839: Pull complete 
    f3a2b77f9928: Pull complete 
    ec092ab086f2: Pull complete 
    82924524a3e0: Pull complete 
    0fc3c53bc799: Pull complete 
    Digest: sha256:d2d8a6420c9fc6b7b403732d3a3c5395d016ebc4996f057aad1aded74202a476
    Status: Downloaded newer image for node:18-slim
    docker.io/library/node:18-slim
    mint # docker run -it node:18-slim bash
    root@5da87a863195:/# mkdir project
    root@5da87a863195:/# cd project
    root@5da87a863195:/project# npx create-strapi-app backend
    Need to install the following packages:
    create-strapi-app@4.15.0
    Ok to proceed? (y) y
    ? Choose your installation type Quickstart (recommended)
    Creating a quickstart project.
    Creating a new Strapi application at /project/backend.
    Creating files.
    Dependencies installed successfully.
    
    Your application was created at /project/backend.
    
    Available commands in your project:
    
      yarn develop
      Start Strapi in watch mode. (Changes in Strapi project files will trigger a server restart)
    
      yarn start
      Start Strapi without watch mode.
    
      yarn build
      Build Strapi admin panel.
    
      yarn strapi
      Display all available commands.
    
    You can start by doing:
    
      cd /project/backend
      yarn develop
    
    Running your Strapi application.
    
    > backend@0.1.0 develop
    > strapi develop
    
    Building your admin UI with development configuration...
    Admin UI built successfully
    [2023-11-03 23:41:10.619] info: The Users & Permissions plugin automatically generated a jwt secret and stored it in .env under the name JWT_SECRET.
    
     Project information                                                          
    
    ┌────────────────────┬──────────────────────────────────────────────────┐
    │ Time               │ Fri Nov 03 2023 23:41:13 GMT+0000 (Coordinated … │
    │ Launched in        │ 4219 ms                                          │
    │ Environment        │ development                                      │
    │ Process PID        │ 213                                              │
    │ Version            │ 4.15.0 (node v18.18.2)                           │
    │ Edition            │ Community                                        │
    │ Database           │ sqlite                                           │
    └────────────────────┴──────────────────────────────────────────────────┘
    
     Actions available                                                            
    
    One more thing...
    Create your first administrator 💻 by going to the administration panel at:
    
    ┌─────────────────────────────┐
    │ http://localhost:1337/admin │
    └─────────────────────────────┘