When I try installing Typescript with npm, I get an error:
npm ERR! Unexpected end of JSON input while parsing near '...latest","mocha":"late'
This is the content of the log file:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'i',
1 verbose cli 'typescript',
1 verbose cli '--save-dev' ]
2 info using npm#6.0.1
3 info using node#v10.0.0
4 verbose npm-session d4b7b23a6f27323f
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/typescript 28ms (from cache)
8 silly fetchPackageMetaData error for typescript#latest Unexpected end of JSON input while parsing near '...latest","mocha":"late'
9 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...latest","mocha":"late'
9 verbose stack at JSON.parse (<anonymous>)
9 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/node_modules/json-parse-better-errors/index.js:7:17)
9 verbose stack at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/body.js:96:50)
9 verbose stack at process._tickCallback (internal/process/next_tick.js:178:7)
10 verbose cwd /Users/Bayo/Documents/Personal/Learning/tstest
11 verbose Darwin 16.7.0
12 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "typescript" "--save-dev"
13 verbose node v10.0.0
14 verbose npm v6.0.1
15 error Unexpected end of JSON input while parsing near '...latest","mocha":"late'
16 verbose exit [ 1, true ]
My current npm version is 6.0.1
My current node version is 10.0.0
Related
I am currently trying to learn react and I cannot add bootstrap as a dependency in my package.json using npm. I am trying the command npm install bootstrap in my terminal and I am in my current project directory. Here is the error:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/lan/.nvm/versions/node/v14.17.0/bin/node',
1 verbose cli '/home/lan/.nvm/versions/node/v14.17.0/bin/npm',
1 verbose cli 'install',
1 verbose cli 'bootstrap',
1 verbose cli '--save'
1 verbose cli ]
2 info using npm#6.14.13
3 info using node#v14.17.0
4 verbose npm-session 2a73fc2953f50908
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/bootstrap 470ms (from cache)
8 silly fetchPackageMetaData error for bootstrap#^5.0.1 Unexpected end of JSON input while parsing near '..."shx":"^0.1.2","time-'
9 timing stage:rollbackFailedOptional Completed in 2ms
10 timing stage:runTopLevelLifecycles Completed in 596ms
11 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '..."shx":"^0.1.2","time-'
11 verbose stack at JSON.parse (<anonymous>)
11 verbose stack at parseJson (/home/lan/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
11 verbose stack at /home/lan/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50
11 verbose stack at processTicksAndRejections (internal/process/task_queues.js:95:5)
12 verbose cwd /media/lan/3561-3761/WebProjects/LearnReact
13 verbose Linux 5.8.0-53-generic
14 verbose argv "/home/lan/.nvm/versions/node/v14.17.0/bin/node" "/home/lan/.nvm/versions/node/v14.17.0/bin/npm" "install" "bootstrap" "--save"
15 verbose node v14.17.0
16 verbose npm v6.14.13
17 error Unexpected end of JSON input while parsing near '..."shx":"^0.1.2","time-'
18 verbose exit [ 1, true ]
I am currently in a Ubuntu 20.04.2 LTS OS.
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'react-bootstrap',
1 verbose cli 'bootstrap'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.17.0
4 verbose npm-session 4004d1d4d37ac517
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/react-bootstrap 521ms
8 silly fetchPackageMetaData error for react-bootstrap#latest Unexpected end of JSON input while parsing near '...,"requirejs":"~2.1.9"'
9 http fetch GET 200 https://registry.npmjs.org/bootstrap 521ms
10 silly fetchPackageMetaData error for bootstrap#latest Unexpected end of JSON input while parsing near '...7bc2df7ec608869c9c8",'
11 timing stage:rollbackFailedOptional Completed in 0ms
12 timing stage:runTopLevelLifecycles Completed in 3560ms
13 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...,"requirejs":"~2.1.9"'
13 verbose stack at JSON.parse (<anonymous>)
13 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
13 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
13 verbose stack at processTicksAndRejections (internal/process/task_queues.js:97:5)
14 verbose cwd D:\Talk2Tutor\material-kit-react-master
15 verbose Windows_NT 10.0.17134
16 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "react-bootstrap" "bootstrap"
17 verbose node v12.17.0
18 verbose npm v6.14.4
19 error Unexpected end of JSON input while parsing near '...,"requirejs":"~2.1.9"'
20 verbose exit [ 1, true ]
I got above error while running npm i react-bootstrap bootstrap. After the error occurred, I tried npm cache clean --force but it didn't resolve my problem. Then I reinstalled node and tried to install dependencies but I still get an error and installation is failed. Any one fixed this error. I tried all the things mentioned in the related question. But it didn't solve my problem. I use node v12.17.0 and npm 6.14.4.
I tried by executing command npm cache clean --force and then executed the command that caused this error and it worked fine.
Upgrade npm using npm-windows-upgrade solved the issue.
After running the command npm cache clean --force . You need to remove the package-lock.json file. This worked for me.
Popper.js is required if you're using Bootstrap JS. Check the docs
I'am trying to install react-native-cli but getting error
npm install -g react-native-cli
getting this error
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'react-native-cli' ]
2 info using npm#6.4.1
3 info using node#v10.15.0
4 verbose npm-session 72c72ae6cf674a04
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 http://registry.npmjs.org/react-native-cli 247ms
8 silly fetchPackageMetaData error for react-native-cli#latest Unexpected token < in JSON at position 0 while parsing near '<HTML><HEAD>
8 silly fetchPackageMetaData <meta h...'
9 timing stage:rollbackFailedOptional Completed in 1ms
10 timing stage:runTopLevelLifecycles Completed in 568ms
11 verbose stack SyntaxError: Unexpected token < in JSON at position 0 while parsing near '<HTML><HEAD>
11 verbose stack <meta h...'
11 verbose stack at JSON.parse (<anonymous>)
11 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
11 verbose stack at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50)
11 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7)
12 verbose cwd C:\Users\Basva
13 verbose Windows_NT 10.0.17134
14 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "react-native-cli"
15 verbose node v10.15.0
16 verbose npm v6.4.1
17 error Unexpected token < in JSON at position 0 while parsing near '<HTML><HEAD>
17 error <meta h...'
18 verbose exit [ 1, true ]
What may be the wrong..!!!?
Make sure whether your npm package correctly install.I solved this problem following below step.Try it..
npm i -g npm
npm cache clean
npm update
npm i
I think https://facebook.github.io/react-native/docs/getting-started.html is more useful for your.
I seem to be struggling with getting npm to install web3
Command used:
npm install web3
Error:
npm ERR! Path must be a string. Received undefined
Logs:
info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'web3' ]
2 info using npm#5.0.4
3 info using node#v8.1.3
4 verbose npm-session 02c74f27df35fda1
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/web3 236ms (from cache)
8 silly pacote tag manifest for web3#latest fetched in 269ms
9 verbose stack TypeError: Path must be a string. Received undefined
9 verbose stack at assertPath (path.js:28:11)
9 verbose stack at Object.relative (path.js:1248:5)
9 verbose stack at computeVersionSpec (/usr/lib/node_modules/npm/lib/install/deps.js:282:27)
9 verbose stack at Installer.normalizeCurrentTree (/usr/lib/node_modules/npm/lib/install.js:370:69)
9 verbose stack at Array.<anonymous> (/usr/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
9 verbose stack at LOOP (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
9 verbose stack at /usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
9 verbose stack at iferr (/usr/lib/node_modules/npm/lib/install.js:328:5)
9 verbose stack at /usr/lib/node_modules/npm/node_modules/iferr/index.js:13:50
9 verbose stack at cb (/usr/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
9 verbose stack at /usr/lib/node_modules/npm/node_modules/call-limit/call-limit.js:22:12
9 verbose stack at _combinedTickCallback (internal/process/next_tick.js:95:7)
9 verbose stack at process._tickCallback (internal/process/next_tick.js:161:9)
10 verbose cwd /home/username
11 verbose Linux 4.11.7-1-ARCH
12 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "web3"
13 verbose node v8.1.3
14 verbose npm v5.0.4
15 error Path must be a string. Received undefined
16 verbose exit [ 1, true ]
I've tried running them with root user as well.
The problem might come from using a beta version of web3 it's not stable at the moment and currently is under heavy development you have one of two options,
either use a stable version 0.19 I think or something like that.
Another thing I would suggest trying is npm --save in order to save the package locally in the project
I'm trying to install mocha on my windows 10 but I'm getting this error on the terminal
$npm install mocha#3.0.0 --save-dev
npm ERR! Unexpected end of input at 1:19983
npm ERR! a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NS\AppData\Roaming\npm-cache\_logs\2017-06-24T21_47_36_363Z-debug.log
this is the log file content
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\NS\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'mocha#3.0.0',
1 verbose cli '--save-dev' ]
2 info using npm#5.0.2
3 info using node#v6.10.2
4 silly install loadCurrentTree
5 silly install readLocalPackageData
6 http fetch GET 200 https://registry.npmjs.org/mocha 34ms (from cache)
7 silly fetchPackageMetaData error for mocha#3.0.0 Unexpected end of input at 1:19983
7 silly fetchPackageMetaData a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4
7 silly fetchPackageMetaData ^
8 verbose stack SyntaxError: Unexpected end of input at 1:19983
8 verbose stack a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4
8 verbose stack ^
8 verbose stack at SyntaxError (native)
8 verbose stack at Object.parseJSON (C:\Users\NS\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\node_modules\jju\lib\parse.js:745:13)
8 verbose stack at parse (C:\Users\NS\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\index.js:10:13)
8 verbose stack at consumeBody.call.then.buffer (C:\Users\NS\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50)
8 verbose stack at process._tickCallback (internal/process/next_tick.js:109:7)
9 verbose cwd C:\Users\NS\node-test
10 verbose Windows_NT 10.0.15063
11 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\NS\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "mocha#3.0.0" "--save-dev"
12 verbose node v6.10.2
13 verbose npm v5.0.2
14 error Unexpected end of input at 1:19983
14 error a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4
14 error ^
15 verbose exit [ 1, true ]
if you are using the latest version of node
try downgrading to the LTS version
//
sudo npm install n -g
sudo n lts
if you are using it in local then use command "npm cache clean --force" to clear cache. Then run your command it will work