How to install Cheerio in Visual Studio Code v 1.87.1

  • Thread starter Darkmisc
  • Start date
  • #1
Darkmisc
203
27
TL;DR Summary
I tried to install Cheerio with the "npm i cheerio" command but get an error message.
Hi everyone

I've just started using Visual Studio Code and tried to install Cheerio using the "npm i cheerio" command. It gives me the following error messages.

Error messages:
npm ERR! code EJSONPARSE

npm ERR! path C:\Users\donbi\Downloads\scraper/package.json

npm ERR! JSON.parse Unexpected token 'p', "npm i{

npm ERR! JSON.parse   "n"... is not valid JSON while parsing 'npm i{

npm ERR! JSON.parse   "name": "scraper",

npm ERR! JSON.parse   "version":'

npm ERR! JSON.parse Failed to parse JSON data.

npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.

This is the full debug log
debug log:
0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using npm@10.2.4
2 info using node@v20.11.1
3 timing npm:load:whichnode Completed in 5ms
4 timing config:load:defaults Completed in 5ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 7ms
6 timing config:load:builtin Completed in 8ms
7 timing config:load:cli Completed in 3ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\donbi\Downloads\scraper\.npmrc Completed in 0ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:C:\Users\donbi\.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:C:\Users\donbi\AppData\Roaming\npm\etc\npmrc Completed in 1ms
14 timing config:load:global Completed in 1ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 24ms
17 timing npm:load:configload Completed in 25ms
18 timing config:load:flatten Completed in 2ms
19 timing npm:load:mkdirpcache Completed in 1ms
20 timing npm:load:mkdirplogs Completed in 1ms
21 verbose title npm i cheerio
22 verbose argv "i" "cheerio"
23 timing npm:load:setTitle Completed in 1ms
24 timing npm:load:display Completed in 0ms
25 verbose logfile logs-max:10 dir:C:\Users\donbi\AppData\Local\npm-cache\_logs\2024-03-08T23_10_41_662Z-
26 verbose logfile C:\Users\donbi\AppData\Local\npm-cache\_logs\2024-03-08T23_10_41_662Z-debug-0.log
27 timing npm:load:logFile Completed in 11ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 85ms
31 timing arborist:ctor Completed in 1ms
32 silly logfile start cleaning logs, removing 2 files
33 timing idealTree Completed in 2ms
34 timing command:i Completed in 16ms
35 verbose stack JSONParseError: Unexpected token 'p', "npm i{
35 verbose stack   "n"... is not valid JSON while parsing 'npm i{
35 verbose stack   "name": "scraper",
35 verbose stack   "version":'
35 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json-fast\lib\index.js:7:61
35 verbose stack     at async #initTree (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:280:21)
35 verbose stack     at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:193:7)
35 verbose stack     at async Promise.all (index 1)
35 verbose stack     at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:159:5)
35 verbose stack     at async Install.exec (C:\Program Files\nodejs\node_modules\npm\lib\commands\install.js:152:5)
35 verbose stack     at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli-entry.js:61:5)
36 verbose cwd C:\Users\donbi\Downloads\scraper
37 verbose Windows_NT 10.0.22631
38 verbose node v20.11.1
39 verbose npm  v10.2.4
40 error code EJSONPARSE
41 error path C:\Users\donbi\Downloads\scraper/package.json
42 error JSON.parse Unexpected token 'p', "npm i{
42 error JSON.parse   "n"... is not valid JSON while parsing 'npm i{
42 error JSON.parse   "name": "scraper",
42 error JSON.parse   "version":'
43 error JSON.parse Failed to parse JSON data.
43 error JSON.parse Note: package.json must be actual JSON, not just JavaScript.
44 verbose exit 1
45 timing npm Completed in 759ms
46 verbose unfinished npm timer reify 1709939442404
47 verbose unfinished npm timer reify:loadTrees 1709939442411
48 verbose unfinished npm timer idealTree:init 1709939442412
49 verbose code 1
50 error A complete log of this run can be found in: C:\Users\donbi\AppData\Local\npm-cache\_logs\2024-03-08T23_10_41_662Z-debug-0.log

Does anyone know what the problem is and how I can fix it?

Thanks
 
Technology news on Phys.org
  • #2
I'm not familiar with either of the packages, but...
that "/" (forward slash) in line 3 Error messages: looks suspicious.
 
  • Like
Likes Darkmisc
  • #3
Tom.G said:
I'm not familiar with either of the packages, but...
that "/" (forward slash) in line 3 Error messages: looks suspicious.
Turns out it was a problem with package.json (thing mentioned in line 3)

The first step in installation was to type "npm init". At the final step, it asked "Is this ok? (yes)". I was supposed to just hit enter, but I typed "y" then hit enter, which messed it up. This is why it later didn't work when I tried to install Cheerio.
 
  • Informative
Likes Tom.G
Back
Top