How to install Cheerio in Visual Studio Code v 1.87.1

  • Thread starter Thread starter Darkmisc
  • Start date Start date
Click For Summary
SUMMARY

The installation of Cheerio in Visual Studio Code v1.87.1 failed due to a malformed package.json file, resulting in an EJSONPARSE error. The user mistakenly entered "y" instead of simply pressing enter during the npm init process, which corrupted the JSON structure. To resolve this issue, the user needs to recreate the package.json file correctly by running npm init again and ensuring to hit enter when prompted for confirmation.

PREREQUISITES
  • Familiarity with Node.js and npm (version 10.2.4)
  • Understanding of JSON structure and syntax
  • Basic knowledge of Visual Studio Code environment
  • Experience with command line interface for executing npm commands
NEXT STEPS
  • Review the structure of package.json files to ensure proper formatting
  • Learn how to use npm init to create a valid project setup
  • Explore common npm error codes and their resolutions
  • Investigate the usage of Cheerio for web scraping in Node.js applications
USEFUL FOR

Developers new to Node.js, those setting up web scraping projects, and anyone troubleshooting npm installation issues in Visual Studio Code.

Darkmisc
Messages
222
Reaction score
31
TL;DR
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.
 
We have many threads on AI, which are mostly AI/LLM, e.g,. ChatGPT, Claude, etc. It is important to draw a distinction between AI/LLM and AI/ML/DL, where ML - Machine Learning and DL = Deep Learning. AI is a broad technology; the AI/ML/DL is being developed to handle large data sets, and even seemingly disparate datasets to rapidly evaluated the data and determine the quantitative relationships in order to understand what those relationships (about the variaboles) mean. At the Harvard &...

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 49 ·
2
Replies
49
Views
12K
  • · Replies 6 ·
Replies
6
Views
4K