skip to Main Content

node v v23.5.0 npm v 11.0.0

when i try to use the command npm install on my package,json file with a command prompt it comes up with these errors.

C:UserslightDocumentssan-project>npm install
npm error code EJSONPARSE
npm error path C:UserslightDocumentssan-project/package.json
npm error JSON.parse Unexpected end of JSON input while parsing empty string
npm error JSON.parse Failed to parse JSON data.
npm error JSON.parse Note: package.json must be actual JSON, not just JavaScript.
npm error A complete log of this run can be found in: C:UserslightAppDataLocalnpm-cache_logs2025-01-03T03_32_16_143Z-debug-0.log

this is the code

{ 
   "name": "demo", 
   "version": "1.0.0", 
   "description": "demo project.", 
   "main": "index.html",
   "scripts": { 
     "lite": "lite-server --port 10001", 
     "start": "npm run lite" 
   }, 
   "author": "nat", 
   "license": "ISC", 
   "devDependencies": { 
     "lite-server": "^1.3.1" 
   } 
}

from my understanding this has no syntax errors, but npm error code EJSONPARSE from my understanding is a syntax error message.
could somebody explain to me what theses error messages mean, and how i should change my code to remedy them.
extra details below

file structure
files

package-lock.json

{
  "name": "san-project",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {}
}

exact error messages from the npm-cache log file

0 verbose cli C:Program Filesnodejsnode.exe C:UserslightAppDataRoamingnpmnode_modulesnpmbinnpm-cli.js
1 info using [email protected]
2 info using [email protected]
3 silly config load:file:C:UserslightAppDataRoamingnpmnode_modulesnpmnpmrc
4 silly config load:file:C:UserslightDocumentssan-project.npmrc
5 silly config load:file:C:Userslight.npmrc
6 silly config load:file:C:UserslightAppDataRoamingnpmetcnpmrc
7 verbose title npm install
8 verbose argv "install"
9 verbose logfile logs-max:10 dir:C:UserslightAppDataLocalnpm-cache_logs2025-01-03T03_32_16_143Z-
10 verbose logfile C:UserslightAppDataLocalnpm-cache_logs2025-01-03T03_32_16_143Z-debug-0.log
11 silly logfile start cleaning logs, removing 1 files
12 silly packumentCache heap:2197815296 maxSize:549453824 maxEntrySize:274726912
13 silly logfile done cleaning log files
14 verbose stack JSONParseError: Unexpected end of JSON input while parsing empty string
14 verbose stack     at C:UserslightAppDataRoamingnpmnode_modulesnpmnode_modulesread-package-json-fastlibindex.js:7:61
14 verbose stack     at async #initTree (C:UserslightAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibarboristbuild-ideal-tree.js:268:21)
14 verbose stack     at async Arborist.buildIdealTree (C:UserslightAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibarboristbuild-ideal-tree.js:178:7)
14 verbose stack     at async Promise.all (index 1)
14 verbose stack     at async Arborist.reify (C:UserslightAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibarboristreify.js:131:5)
14 verbose stack     at async Install.exec (C:UserslightAppDataRoamingnpmnode_modulesnpmlibcommandsinstall.js:150:5)
14 verbose stack     at async Npm.exec (C:UserslightAppDataRoamingnpmnode_modulesnpmlibnpm.js:207:9)
14 verbose stack     at async module.exports (C:UserslightAppDataRoamingnpmnode_modulesnpmlibclientry.js:69:5)
15 error code EJSONPARSE
16 error path C:UserslightDocumentssan-project/package.json
17 error JSON.parse Unexpected end of JSON input while parsing empty string
18 error JSON.parse Failed to parse JSON data.
18 error JSON.parse Note: package.json must be actual JSON, not just JavaScript.
19 silly unfinished npm timer reify 1735875137942
20 silly unfinished npm timer reify:loadTrees 1735875137944
21 silly unfinished npm timer idealTree:init 1735875137945
22 verbose cwd C:UserslightDocumentssan-project
23 verbose os Windows_NT 10.0.26100
24 verbose node v23.5.0
25 verbose npm  v11.0.0
26 verbose exit 1
27 verbose code 1
28 error A complete log of this run can be found in: C:UserslightAppDataLocalnpm-cache_logs2025-01-03T03_32_16_143Z-debug-0.log

tried to search up the errors to get a better insight on my problem

2

Answers


  1. Chosen as BEST ANSWER

    I forgot to save the file lol!


  2. Line 3 of your top error message indicates that the problem is with the file package.json. I assume the contents of that have been reproduced.

    Those contents parse correctly as JSON. I used https://jsonformatter.org/json-parser to verify that. So it’s not a syntax error, it’s something else. It only looks like a syntax error.

    I notice that in that path there are several characters plus one / character. This suggests there is some hybrid windows/linux coding going on. The error message also indicates something strange – it ends when it encounters end of file while not parsing anything. This suggests to me that either the package file has a stray bad (non-printing) character, or somehow the system is reading the wrong file (because of the switching slashes.

    That’s what I would check.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search