How to install Cheerio in Visual Studio Code v 1.87.1

  • Thread starter Thread starter Darkmisc
  • Start date Start date
AI Thread Summary
The user encountered an error while trying to install Cheerio in Visual Studio Code using the command "npm i cheerio." The error messages indicated a JSON parsing issue with the package.json file, specifically noting an unexpected token and that the file must contain valid JSON. The root cause was identified as a mistake made during the npm initialization process. Instead of simply pressing enter when prompted to confirm the package details, the user typed "y," which corrupted the package.json file. The solution involved reinitializing the project correctly by running "npm init" and ensuring the confirmation step was completed properly.
Darkmisc
Messages
222
Reaction score
31
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.

[CODE title="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.[/CODE]

This is the full debug log
[CODE title="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
[/CODE]

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

Thanks
 
Technology news on Phys.org
I'm not familiar with either of the packages, but...
that "/" (forward slash) in line 3 Error messages: looks suspicious.
 
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Back
Top