npm err ! unxepcter tocken occerd while installing react-native-cli - node.js

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.

Related

getting following error whiling running npm install -g create-react-app

when i tried to run npm install -g create-react-app to create react app getting following error.
when i tired to run "npm install -g npm" getting same error.
Could you please guide me solve this issue ?
debug.log file,
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 '-g',
1 verbose cli 'create-react-app'
1 verbose cli ]
2 info using npm#6.14.13
3 info using node#v14.17.1
4 verbose npm-session 5c7b621106479737
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for create-react-app#latest error:0909006C:PEM routines:get_name:no start line
8 timing stage:rollbackFailedOptional Completed in 1ms
9 timing stage:runTopLevelLifecycles Completed in 162ms
10 verbose stack Error: error:0909006C:PEM routines:get_name:no start line
10 verbose stack at Object.createSecureContext (_tls_common.js:149:17)
10 verbose stack at Object.connect (_tls_wrap.js:1597:48)
10 verbose stack at HttpsAgent.createConnection (https.js:137:22)
10 verbose stack at HttpsAgent.createSocket (C:\Program Files\nodejs\node_modules\npm\node_modules\agentkeepalive\lib\_http_agent.js:265:26)
10 verbose stack at HttpsAgent.createSocket (C:\Program Files\nodejs\node_modules\npm\node_modules\agentkeepalive\lib\agent.js:77:11)
10 verbose stack at HttpsAgent.addRequest (C:\Program Files\nodejs\node_modules\npm\node_modules\agentkeepalive\lib\_http_agent.js:239:10)
10 verbose stack at new ClientRequest (_http_client.js:305:16)
10 verbose stack at request (https.js:333:10)
10 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:54:17
10 verbose stack at new Promise (<anonymous>)
10 verbose stack at fetch (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:41:10)
10 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\index.js:332:14
10 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\promise-retry\index.js:29:24
11 verbose cwd C:\Users\user\development
12 verbose Windows_NT 10.0.19042
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "create-react-app"
14 verbose node v14.17.1
15 verbose npm v6.14.13
16 error code ERR_OSSL_PEM_NO_START_LINE
17 error error:0909006C:PEM routines:get_name:no start line
18 verbose exit [ 1, true ]```
Use the below commands to set up the development environment.
npx create-react-app my-app
cd my-app
npm start
Always follow the Documentation :)

Failed in adding bootstrap in package.json using npm

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.

Every npm install gives "npm ERR! Only absolute URLs are supported"

Tried nodeJS 8.12 and 10.11
Running latest npm 6.4.1
When trying to install any package i.e. (npm install -g firebase-tools) I get npm ERR! Only absolute URLs are supported.
Uninstalled and reinstall nodeJS. Still broken. Any help appreciated.
Debug Log
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 'firebase-tools' ]
2 info using npm#6.4.1
3 info using node#v10.11.0
4 verbose npm-session 442f99e3eed77ef2
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for firebase-tools#latest Only absolute URLs are supported
8 timing stage:rollbackFailedOptional Completed in 0ms
9 timing stage:runTopLevelLifecycles Completed in 206ms
10 verbose stack TypeError: Only absolute URLs are supported
10 verbose stack at getNodeRequestOptions (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\request.js:131:11)
10 verbose stack at fetch.Promise (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:44:21)
10 verbose stack at new Promise (<anonymous>)
10 verbose stack at fetch (C:\Program
Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:41:10)
10 verbose stack at retry (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\index.js:332:14)
10 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\promise-retry\index.js:29:24
11 verbose cwd C:\Users\Mine
12 verbose Windows_NT 10.0.17134
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
14 verbose node v10.11.0
15 verbose npm v6.4.1
16 error Only absolute URLs are supported
17 verbose exit [ 1, true ]
Solution moved from #StevePerry's question post.
Had to edit .npmrc file located at C:\Users\yourName\.npmrc
It had a bunch of lines. Only ones needed for me:
//registry.npmjs.org/:_authToken="your_auth_token"
scope="your_name"
#"your_name":registry=https://registry.npmjs.org/

Error installing Typescript using npm

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

mocha installation error: Unexpected end of input

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

Resources