SyntaxError: /usr/local/lib/node_modules/npm/package.json: Unexpected token '', ""... is not valid JSON

Open
#20 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
docker, node.js
Domain
build-system

Research direction

Start by reproducing docker compose up -d and inspect the Dockerfile step that runs npm ci --include=dev with the node:19.5.0-alpine image. Check the referenced package.json and package-lock.json files alongside the npm error. Done means the compose build completes successfully.

Written by the indexing model from the issue text.

Description

Cannot success following docker desktop Learning Center 's instruction

  1. My docker is installed with wsl2 backend
  2. Container type is linus container
  3. Cmd run in Idea's terminal , also wrong when run in powershell.
docker compose up -d :Logs

 docker compose up -d
[+] Building 0.0s (0/0)  docker:default
[+] Building 3.1s (9/12)                                                                                                                                                                                             docker:default
 => [todo-app internal] load build definition from Dockerfile                                                                                                                                                                  0.0s
 => => transferring dockerfile: 1.29kB                                                                                                                                                                                         0.0s 
 => [todo-app] resolve image config for docker.io/docker/dockerfile:1                                                                                                                                                          1.6s 
 => CACHED [todo-app] docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021                                                                                     0.0s
 => [todo-app internal] load metadata for docker.io/library/node:19.5.0-alpine                                                                                                                                                 0.9s 
 => [todo-app internal] load .dockerignore                                                                                                                                                                                     0.0s
 => => transferring context: 706B                                                                                                                                                                                              0.0s 
 => [todo-app stage-0 1/6] FROM docker.io/library/node:19.5.0-alpine@sha256:4619ec6c9a43ab4edfa12cf96745319c3ca43aff9dd630ab20e684dd3632318e                                                                                   0.0s 
 => [todo-app internal] load build context                                                                                                                                                                                     0.0s 
 => => transferring context: 904B                                                                                                                                                                                              0.0s 
 => CACHED [todo-app stage-0 2/6] WORKDIR /usr/src/app                                                                                                                                                                         0.0s 
 => ERROR [todo-app stage-0 3/6] RUN --mount=type=bind,source=package.json,target=package.json     --mount=type=bind,source=package-lock.json,target=package-lock.json     --mount=type=cache,target=/root/.npm     npm ci --  0.3s
------
 > [todo-app stage-0 3/6] RUN --mount=type=bind,source=package.json,target=package.json     --mount=type=bind,source=package-lock.json,target=package-lock.json     --mount=type=cache,target=/root/.npm     npm ci --include=dev:  
0.312 undefined:1
0.312
0.312
0.312
0.312 SyntaxError: /usr/local/lib/node_modules/npm/package.json: Unexpected token '', ""... is not valid JSON
0.312     at parse (<anonymous>)
0.312     at Module._extensions..json (node:internal/modules/cjs/loader:1315:39)
0.312     at Module.load (node:internal/modules/cjs/loader:1103:32)
0.312     at Module._load (node:internal/modules/cjs/loader:942:12)
0.312     at Module.require (node:internal/modules/cjs/loader:1127:19)
0.312     at require (node:internal/modules/helpers:112:18)
0.312     at createEnginesValidation (/usr/local/lib/node_modules/npm/lib/cli.js:7:15)
0.312     at module.exports (/usr/local/lib/node_modules/npm/lib/cli.js:78:27)
0.312     at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:25)
0.312     at Module._compile (node:internal/modules/cjs/loader:1246:14)
0.312
0.312 Node.js v19.5.0
------
failed to solve: process "/bin/sh -c npm ci --include=dev" did not complete successfully: exit code: 1

Dominant language
EJS
Stars
234
Forks
658
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from docker/multi-container-app

All issues in docker/multi-container-app

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.