Errors of Unexpected token in JSON at position XXX while parsing near - node.js

I npm install on a directory with a package.json for my company project. However, it keeps giving me various errors of Unexpected token in JSON at position....
I have done npm cache clean --force, npm cache verify etc. as suggested by When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0)
However, the issue still persists. I do not configure proxy though as my machine is not on any corporate proxy.
Anyway, I attach the npm log content and package.json file content for your reference. Please kindly help to advise me what's wrong and how to resolve this issue.
npm log:
122 silly pacote range manifest for array-includes#^3.1.1 fetched in 64ms
123 http fetch GET 304 https://registry.npmjs.org/typescript 459ms (from cache)
124 silly pacote range manifest for popper.js#^1.14.1 fetched in 109ms
125 warn deprecated popper.js#1.16.1: You can find the new Popper v2 at #popperjs/core, this package is dedicated to the legacy v1
126 silly fetchPackageMetaData error for typescript#^3.8.3 Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
127 http fetch GET 304 https://registry.npmjs.org/array.prototype.flat 96ms (from cache)
128 silly pacote range manifest for array.prototype.flat#^1.2.3 fetched in 99ms
129 http fetch GET 304 https://registry.npmjs.org/contains-path 94ms (from cache)
130 silly pacote range manifest for contains-path#^0.1.0 fetched in 95ms
131 http fetch GET 304 https://registry.npmjs.org/debug 85ms (from cache)
132 http fetch GET 304 https://registry.npmjs.org/doctrine 75ms (from cache)
133 silly pacote range manifest for debug#^2.6.9 fetched in 89ms
134 silly pacote version manifest for doctrine#1.5.0 fetched in 79ms
...
307 http fetch GET 304 https://registry.npmjs.org/rxjs 71ms (from cache)
308 silly fetchPackageMetaData error for rxjs#^6.6.0 Unexpected token in JSON at position 133105 while parsing near '...\r\n-----END PGP8'�� C��m�4���
r\n"},"e...'
309 silly pacote range manifest for through#^2.3.6 fetched in 60ms
310 http fetch GET 304 https://registry.npmjs.org/deep-is 51ms (from cache)
...
479 silly pacote range manifest for typescript-eslint-parser#^18.0.0 fetched in 9ms
480 silly resolveWithNewModule typescript-eslint-parser#18.0.0 checking installable status
481 http fetch GET 304 https://registry.npmjs.org/typescript 67ms (from cache)
482 silly fetchPackageMetaData error for typescript#^3.8.3 Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
483 timing stage:rollbackFailedOptional Completed in 1ms
484 timing stage:runTopLevelLifecycles Completed in 2633ms
485 silly saveTree typescript-type-definitions#1.0.0
...
485 silly saveTree ├── prettier#1.19.1
485 silly saveTree └── typescript-eslint-parser#18.0.0
486 verbose stack SyntaxError: Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
486 verbose stack at JSON.parse (<anonymous>)
486 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
486 verbose stack at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)
486 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7)
487 verbose cwd /home/rugrat/Projects/aleng/ui/includes
488 verbose Linux 4.4.0-189-generic
489 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "install"
490 verbose node v10.22.0
491 verbose npm v6.14.8
492 error Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
493 verbose exit [ 1, true ]
Package.json:
{
"name": "typescript-type-definitions",
"version": "1.0.0",
"description": "Type definitions for TypeScript",
"main": "typescript/main.js",
"dependencies": {},
"devDependencies": {
"#types/bootbox": "^4.4.36",
"#types/bootstrap": "^4.3.2",
"#types/bootstrap-3-typeahead": "^4.0.1",
"#types/bootstrap-select": "^1.11.1",
"#types/bootstrap-switch": "0.0.31",
"#types/bootstrap-toggle": "^2.2.1",
"#types/bootstrap-treeview": "^1.20.0",
"#types/d3": "^5.7.2",
"#types/datatables.net": "^1.10.19",
"#types/datatables.net-select": "^1.2.6",
"#types/jquery": "^1.10.35",
"#types/jquerymobile": "^1.4.30",
"#types/jqueryui": "^1.12.8",
"#types/x-editable": "^1.5.29",
"apidoc": "^0.25.0",
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-typescript": "^0.12.0",
"prettier": "^1.19.1",
"typescript": "^3.8.3",
"typescript-eslint-parser": "^18.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "XXX XXX",
"license": "ISC"
}
I also added the output for npm config and npm config ls -l below.
Output for npm config:
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v10.22.0 linux x64"
; builtin config undefined
globalconfig = "/etc/npmrc"
globalignorefile = "/etc/npmignore"
prefix = "/usr/local"
; node bin location = /usr/bin/node
; cwd = /home/myname
; HOME = /home/myname
; "npm config ls -l" to show all defaults.
Output of npm config ls -l:
; cli configs
long = true
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v10.22.0 linux x64"
; builtin config undefined
globalconfig = "/etc/npmrc"
globalignorefile = "/etc/npmignore"
prefix = "/usr/local"
; default values
access = null
allow-same-version = false
also = null
always-auth = false
audit = true
audit-level = "low"
auth-type = "legacy"
before = null
bin-links = true
browser = null
ca = null
cache = "/home/myname/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cafile = undefined
cert = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
dry-run = false
editor = "vi"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
format-package-lock = true
fund = true
git = "git"
git-tag-version = true
global = false
global-style = false
; globalconfig = "/usr/local/etc/npmrc" (overridden)
; globalignorefile = "/usr/local/etc/npmignore" (overridden)
group = 1000
ham-it-up = false
heading = "npm"
https-proxy = null
if-present = false
ignore-prepublish = false
ignore-scripts = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "/home/myname/.npm-init.js"
init-version = "1.0.0"
json = false
key = null
legacy-bundling = false
link = false
local-address = undefined
loglevel = "notice"
logs-max = 10
; long = false (overridden)
maxsockets = 50
message = "%s"
; metrics-registry = null (overridden)
node-options = null
node-version = "10.22.0"
noproxy = null
offline = false
onload-script = null
only = null
optional = true
otp = null
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "/usr" (overridden)
preid = ""
production = false
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
scripts-prepend-node-path = "warn-only"
searchexclude = null
searchlimit = 20
searchopts = ""
searchstaleness = 900
send-metrics = false
shell = "/bin/bash"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "/tmp"
umask = 2
unicode = true
unsafe-perm = true
update-notifier = true
usage = false
user = 0
; user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} {ci}" (overridden)
userconfig = "/home/myname/.npmrc"
version = false
versions = false
viewer = "man"
I found .npmrc in /usr/lib/node_modules/npm and it is empty.
I found npmrc in /usr/local/lib/node_modules/npm and its content:
globalconfig=/etc/npmrc
globalignorefile=/etc/npmignore
prefix=/usr/local
Do you find anything odd from the contents above? I read npm-config and npmrc but can't find anything helpful.
Thanks.

I had the same error, I deleted my package-lock.json file and my node_module folder and it worked.

Related

'parcel' is not recognized as an internal or external command, operable program or batch file. ERROR for Parcel bundler in Vanilla TYPESCRIPT Code

This error is showed up when I ran the code for an Arkanoid Game published on freecodecamp articles. I am not able to set up the configuration correctly for the game. I expected it to run the game but it didn't do the same. While debugging it kept throwing errors regarding its build. I have no idea as I have learned it online but this error is not getting resolve.
I am attaching both the debugger image and the error image along with the log file text, where it showed the error.
DEBUG CONSOLE
TERMINAL
0 verbose cli [
0 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli 'start'
0 verbose cli ]
1 info using npm#7.5.3
2 info using node#v15.9.0
3 timing config:load:defaults Completed in 4ms
4 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 5ms
5 timing config:load:builtin Completed in 5ms
6 timing config:load:cli Completed in 6ms
7 timing config:load:env Completed in 2ms
8 timing config:load:file:D:\arkanoid-ts-startHere\.npmrc Completed in 1ms
9 timing config:load:project Completed in 2ms
10 timing config:load:file:C:\Users\WELCOME\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Users\WELCOME\AppData\Roaming\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 2ms
17 timing config:load:setEnvs Completed in 3ms
18 timing config:load Completed in 27ms
19 verbose npm-session 84c35795bdcebad3
20 timing npm:load Completed in 60ms
21 timing command:run-script Completed in 146ms
22 timing command:start Completed in 163ms
23 verbose stack Error: command failed
23 verbose stack at ChildProcess.<anonymous> (C:\Program
Files\nodejs\node_modules\npm\node_modules\#npmcli\promise-spawn\index.js:64:27)
23 verbose stack at ChildProcess.emit (node:events:378:20)
23 verbose stack at maybeClose (node:internal/child_process:1067:16)
23 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
24 verbose pkgid ts-parcel#1.0.0
25 verbose cwd D:\arkanoid-ts-startHere
26 verbose Windows_NT 10.0.19042
27 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
28 verbose node v15.9.0
29 verbose npm v7.5.3
30 error code 1
31 error path D:\arkanoid-ts-startHere
32 error command failed
33 error command C:\WINDOWS\system32\cmd.exe /d /s /c parcel serve src/index.html
34 verbose exit 1
This is package.json file
{
"name": "ts-parcel",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "parcel serve src/index.html",
"watch": "parcel watch src/index.html"
},
"type": "module",
"author": "",
"license": "ISC",
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.11.0",
"#typescript-eslint/parser": "^4.11.0",
"eslint": "^7.16.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.0",
"parcel": "^1.12.4",
"prettier": "^2.2.1",
"typescript": "^4.1.3"
}
}
This is index.ts file
import {CanvasView} from './view/CanvasView';
import {Ball} from './sprites/Ball';
import {Brick} from './sprites/Brick';
import {Paddle} from './sprites/Paddle';
import {Collision} from './Collision';
//Images
import PADDLE_IMAGE from './images/paddle.png';
import BALL_IMAGE from './images/ball.png';
import BRICK_IMAGE from './images/brick.png';
//level and colors
import{
PADDLE_SPEED,
PADDLE_WIDTH,
PADDLE_HEIGHT,
PADDLE_STARTX,
BALL_SPEED,
BALL_SIZE,
BALL_STARTX,
BALL_STARTY
} from './setup';
//helpers
import {createBricks} from './helpers';
let gameOver = false;
let score = 0;
function setGameOver(view: CanvasView){
view.drawInfo('Game Over!');
gameOver = false;
}
function setGameWin(view: CanvasView){
view.drawInfo('Game Won!!!');
gameOver = false;
}
function gameLoop(
view: CanvasView,
bricks:Brick[],
paddle: Paddle,
ball: Ball,
collision: Collision
){
console.log("draw!");
view.clear();
view.drawBricks(bricks);
view.drawSprite(paddle);
view.drawSprite(ball);
//move ball
ball.moveBall();
//move paddle and check as it won't exit the playField
if(
(paddle.isMovingLeft && paddle.pos.x > 0) ||
(paddle.isMovingRight && paddle.pos.x < view.canvas.width - paddle.width)
){
paddle.movePaddle();
}
collision.checkBallCollision(ball, paddle, view);
const collidingBrick = collision.isCollidingBricks(ball, bricks);
if(collidingBrick){
score += 1;
view.drawScore(score);
}
//GAME OVER!!! when ball leaves playField
if(ball.pos.y > view.canvas.height) gameOver = true;
//if game won, set gameOver and display win
if(bricks.length === 0) return setGameWin(view);
//return if gameOver and don't run the requestAnimationFrame
if(gameOver) return setGameOver(view);
requestAnimationFrame(() => gameLoop(view,bricks,paddle,ball,collision));
}
function startGame(view:CanvasView){
//reset display
score = 0;
view.drawInfo('');
view.drawScore(0);
//create collision
const collision = new Collision();
//create all bricks
const bricks = createBricks();
//create all paddle
const paddle = new Paddle(
PADDLE_SPEED,
PADDLE_WIDTH,
PADDLE_HEIGHT,
{
x: PADDLE_STARTX,
y: view.canvas.height - PADDLE_HEIGHT - 5
},
PADDLE_IMAGE
)
//create a ball
const ball = new Ball(
BALL_SPEED,
BALL_SIZE,
{x: BALL_STARTX, y: BALL_STARTY},
BALL_IMAGE
);
gameLoop(view, bricks, paddle, ball, collision);
}
//create a view
const view = new CanvasView('#playField');
view.initStartButton(startGame);
This is CanvasView.ts file
import {Brick} from '../sprites/Brick';
import {Ball} from '../sprites/Ball';
import {Paddle} from '../sprites/Paddle';
import { BRICK_IMAGES } from '~/setup';
export class CanvasView{
canvas: HTMLCanvasElement;
private context: CanvasRenderingContext2D | null;
private scoreDisplay: HTMLObjectElement | null;
private start: HTMLObjectElement | null;
private info: HTMLObjectElement| null;
constructor(canvasName: string){
this.canvas = document.querySelector(canvasName) as HTMLCanvasElement;
this.context = this.canvas.getContext('2d');
this.scoreDisplay = document.querySelector('#score');
this.start = document.querySelector('#start');
this.info = document.querySelector('#info');
}
clear(): void{
this.context?.clearRect(0,0,this.canvas.width, this.canvas.height);
}
initStartButton(startFunction: (view:CanvasView) => void): void{
this.start?.addEventListener('click', () => startFunction(this));
}
drawScore(score: number): void{
if(this.scoreDisplay) this.scoreDisplay.innerHTML = score.toString();
}
drawInfo(text: string): void{
if(this.info) this.info.innerHTML = text;
}
drawSprite(brick: Brick | Paddle | Ball): void{
if(!brick) return;
this.context?.drawImage(
brick.image,
brick.pos.x,
brick.pos.y,
brick.width,
brick.height
);
}
drawBricks(bricks: Brick[]): void{
bricks.forEach(brick => this.drawSprite(brick));
}
}
The above codes are the mainframe of the game. Hope it helps to resolve.
To be able to load an ES module, we need to set “type”: “module” in this file or, as an alternative, we can use the .mjs file extension as against the usual .js file extension.
In your package.json file add this:
{
"type": "module",
}
For an example:
{
"name": "esm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"type": "module",
"author": "",
"license": "ISC"
}
If this doesn't work uninstalling both global and local versions of parcel:
npm uninstall parcel
npm uninstall -g parcel
Then install it using this command:
npm install parcel --save-dev
I have been getting this error while using parcel index.html to start the parcel deployment server.
On reading the official documentation I found out the correct command to do that:
npx parcel index.html
It worked as expected on using that command!

grunt: problems npm with proxy

I am having problems with the proxy but I think it is ok about the configuration. It is when I just executing npm install.
my error in console is:
my file npm-debug.log tells me:
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 'grunt-contrib-concat',
1 verbose cli '--dev-save',
1 verbose cli '--global' ]
2 info using npm#2.11.3
3 info using node#v0.12.7
4 verbose install initial load of C:\Users\dmora\AppData\Roaming\npm\package.json
5 verbose readDependencies loading dependencies from C:\Users\dmora\AppData\Roaming\npm\package.json
6 silly cache add args [ 'grunt-contrib-concat', null ]
7 verbose cache add spec grunt-contrib-concat
8 silly cache add parsed spec { raw: 'grunt-contrib-concat',
8 silly cache add scope: null,
8 silly cache add name: 'grunt-contrib-concat',
8 silly cache add rawSpec: '',
8 silly cache add spec: '*',
8 silly cache add type: 'range' }
9 silly addNamed grunt-contrib-concat#*
10 verbose addNamed "*" is a valid semver range for grunt-contrib-concat
11 silly addNameRange { name: 'grunt-contrib-concat', range: '*', hasData: false }
12 silly mapToRegistry name grunt-contrib-concat
13 silly mapToRegistry using default registry
14 silly mapToRegistry registry http://registry.npmjs.org/
15 silly mapToRegistry uri http://registry.npmjs.org/grunt-contrib-concat
16 verbose addNameRange registry:http://registry.npmjs.org/grunt-contrib-concat not in flight; fetching
17 verbose request uri http://registry.npmjs.org/grunt-contrib-concat
18 verbose request no auth needed
19 info attempt registry request try #1 at 17:48:55
20 verbose request id 5852220cb81144b0
21 http request GET http://registry.npmjs.org/grunt-contrib-concat
22 info retry will retry, error on last attempt: Error: connect ECONNREFUSED
23 info attempt registry request try #2 at 17:49:06
24 http request GET http://registry.npmjs.org/grunt-contrib-concat
25 info retry will retry, error on last attempt: Error: connect ECONNREFUSED
26 info attempt registry request try #3 at 17:50:07
27 http request GET http://registry.npmjs.org/grunt-contrib-concat
28 verbose stack Error: connect ECONNREFUSED
28 verbose stack at exports._errnoException (util.js:746:11)
28 verbose stack at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
29 verbose cwd D:\_PROYECTOS\Serunet CK.Client\SeruWeb\SN.CK.Front\Serunet.CK.Client.Web.Tests.ShowInBrowse
30 error Windows_NT 6.1.7601
31 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "grunt-contrib-concat" "--dev-save" "--global"
32 error node v0.12.7
33 error npm v2.11.3
34 error code ECONNREFUSED
35 error errno ECONNREFUSED
36 error syscall connect
37 error Error: connect ECONNREFUSED
37 error at exports._errnoException (util.js:746:11)
37 error at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
37 error { [Error: connect ECONNREFUSED]
37 error code: 'ECONNREFUSED',
37 error errno: 'ECONNREFUSED',
37 error syscall: 'connect' }
38 error If you are behind a proxy, please make sure that the
38 error 'proxy' config is set properly. See: 'npm help config'
39 verbose exit [ 1, true ]
Finally I insert my .npmrc file:
proxy=http://Domain\user:password#xx.xx.xx.xx:8080/
https-proxy=http://Domain\user:password#xx.xx.xx.xx:8080/
registry=http://registry.npmjs.org/
strict-ssl = false
ca = null
.npmrc file is in directory: c:\users\myuser\.npmrc
I think everything is correct but it is giving me that errors.
What is wrong in configuration?
It was problem of the proxy of that corporation. Where I am now it is working fine. For me it is resolved.

npm install throws 407 error with HTML

when I run npm install I get a very long error saying error parsing json and continues with the source code of a HTML page that tells me I have a '407 Proxy Authentication Required' error.
The full log can be seen here: http://pastebin.com/T7a4zuYK
this is what npm config list returns:
; cli configs
registry = "http://registry.npmjs.org/"
user-agent = "npm/1.4.28 node/v0.10.34 win32 x64"
; userconfig C:\Users\PV01054\.npmrc
https-proxy = "http://localhost:3128/"
proxy = "http://localhost:3128/"
registry = "http://registry.npmjs.org/"
; builtin config undefined
prefix = "C:\\Users\\PV01054\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\\node.exe
; cwd = C:\Repos\randstad-nl
; HOME = C:\Users\PV01054
; 'npm config ls -l' to show all defaults.

npm - https proxy error using nodeJS

This is the error, doesn't make me install nothing:
npm WARN invalid config https-proxy="http:"
npm WARN invalid config Must be a full url with 'http://'
I try a lot of things:
uninstall/install node and npm
clean npm cache
npm config delete https-proxy
set npm ssl to false
npm config set registry http://registry.npmjs.org/
tried to override it with npm config set https-proxy http://proxy.company.com:8080
open and change manually npmrc global and local files
I get response doing ping to registry.npmjs.org and google.es in console.
Even I uninstall all node and make a new compilation and error persist.
npm config get https-proxy
and
npm config get http-proxy
returns me null both.
my /home/usertv/npm-debug.log
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 'install',
1 verbose cli '-g',
1 verbose cli 'cordova' ]
2 info using npm#1.3.21
3 info using node#v0.10.24
4 warn invalid config https-proxy="http:"
5 warn invalid config Must be a full url with 'http://'
6 verbose cache add [ 'cordova', null ]
7 verbose cache add name=undefined spec="cordova" args=["cordova",null]
8 verbose parsed url { protocol: null,
8 verbose parsed url slashes: null,
8 verbose parsed url auth: null,
8 verbose parsed url host: null,
8 verbose parsed url port: null,
8 verbose parsed url hostname: null,
8 verbose parsed url hash: null,
8 verbose parsed url search: null,
8 verbose parsed url query: null,
8 verbose parsed url pathname: 'cordova',
8 verbose parsed url path: 'cordova',
8 verbose parsed url href: 'cordova' }
9 silly lockFile a98f2055-cordova cordova
10 verbose lock cordova /root/.npm/a98f2055-cordova.lock
11 silly lockFile a98f2055-cordova cordova
12 silly lockFile a98f2055-cordova cordova
13 verbose addNamed [ 'cordova', '' ]
14 verbose addNamed [ null, '*' ]
15 silly lockFile de8d9fad-cordova cordova#
16 verbose lock cordova# /root/.npm/de8d9fad-cordova.lock
17 silly addNameRange { name: 'cordova', range: '*', hasData: false }
18 verbose url raw cordova
19 verbose url resolving [ 'http://registry.npmjs.org/', './cordova' ]
20 verbose url resolved http://registry.npmjs.org/cordova
21 info trying registry request attempt 1 at 12:25:02
22 http GET http://registry.npmjs.org/cordova
23 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
24 info trying registry request attempt 2 at 12:25:13
25 http GET http://registry.npmjs.org/cordova
26 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
27 info trying registry request attempt 3 at 12:26:13
28 http GET http://registry.npmjs.org/cordova
29 silly lockFile de8d9fad-cordova cordova#
30 silly lockFile de8d9fad-cordova cordova#
31 error network getaddrinfo ENOTFOUND
31 error network This is most likely not a problem with npm itself
31 error network and is related to network connectivity.
31 error network In most cases you are behind a proxy or have bad network settings.
31 error network
31 error network If you are behind a proxy, please make sure that the
31 error network 'proxy' config is set properly. See: 'npm help config'
32 error System Linux 3.2.0-4-686-pae
33 error command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova"
34 error cwd /home/usertv
35 error node -v v0.10.24
36 error npm -v 1.3.21
37 error syscall getaddrinfo
38 error code ENOTFOUND
39 error errno ENOTFOUND
40 verbose exit [ 1, true ]
my npm config ls -l
; cli configs
long = true
registry = "http://registry.npmjs.org/"
; userconfig /home/usertv/.npmrc
registry = "http://registry.npmjs.org/"
strict-ssl = false
; globalconfig /usr/local/etc/npmrc
registry = "http://registry.npmjs.org/"
; default values
always-auth = false
bin-links = true
browser = null
cache = "/home/usertv/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cert = null
color = true
depth = null
description = true
dev = false
editor = "vi"
email = null
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
git = "git"
git-tag-version = true
global = false
globalconfig = "/usr/local/etc/npmrc"
globalignorefile = "/usr/local/etc/npmignore"
group = 1000
heading = "npm"
https-proxy = null
ignore-scripts = false
init-module = "/home/usertv/.npm-init.js"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
json = false
key = null
link = false
local-address = undefined
loglevel = "http"
; long = false (overridden)
message = "%s"
node-version = "v0.10.24"
npat = false
onload-script = false
optional = true
parseable = false
prefix = "/usr/local"
production = false
proprietary-attribs = true
proxy = null
rebuild-bundle = true
; registry = "https://registry.npmjs.org/" (overridden)
rollback = true
save = false
save-bundle = false
save-dev = false
save-optional = false
searchexclude = null
searchopts = ""
searchsort = "name"
shell = "/bin/bash"
shrinkwrap = true
sign-git-tag = false
; strict-ssl = true (overridden)
tag = "latest"
tmp = "/home/usertv/tmp"
umask = 18
unicode = true
unsafe-perm = true
usage = false
user = 0
user-agent = "node/v0.10.24 linux ia32"
userconfig = "/home/usertv/.npmrc"
username = ""
version = false
versions = false
viewer = "man"
It was a connection problem.
I remember thatI played with proxy configuration by mistake like this :
npm config set proxy http://localhost:8080/
npm config set https-proxy http://localhost:8080/
npm config set strict-ssl false
which made npm client attempts to hit localhost:8080 to pull the module rather than the correct internet endpoint.
so after couple of days of frustration i visited this link
https://docs.npmjs.com/cli/config
then run
npm config edit
which opened a file inside that file i removed those three lines i added above , then everything worked fine.

Unable to install any module in nodejs.

I am not able to install any package with node js. Eventually not able to use it at all. Getting the following log when trying to run "npm install socket" :
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\NODEJS\\\\node.exe',
1 verbose cli 'C:\\NODEJS\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'socket' ]
2 info using npm#1.3.10
3 info using node#v0.10.18
4 verbose node symlink C:\NODEJS\\node.exe
5 verbose cache add [ 'socket', null ]
6 verbose cache add name=undefined spec="socket" args=["socket",null]
7 verbose parsed url { protocol: null,
7 verbose parsed url slashes: null,
7 verbose parsed url auth: null,
7 verbose parsed url host: null,
7 verbose parsed url port: null,
7 verbose parsed url hostname: null,
7 verbose parsed url hash: null,
7 verbose parsed url search: null,
7 verbose parsed url query: null,
7 verbose parsed url pathname: 'socket',
7 verbose parsed url path: 'socket',
7 verbose parsed url href: 'socket' }
8 silly lockFile 897d2105-socket socket
9 verbose lock socket C:\Users\cbaid\AppData\Roaming\npm-cache\897d2105-socket.lock
10 silly lockFile 897d2105-socket socket
11 silly lockFile 897d2105-socket socket
12 verbose addNamed [ 'socket', '' ]
13 verbose addNamed [ null, '*' ]
14 silly lockFile 45707214-socket socket#
15 verbose lock socket# C:\Users\cbaid\AppData\Roaming\npm-cache\45707214-socket.lock
16 silly addNameRange { name: 'socket', range: '*', hasData: false }
17 verbose url raw socket
18 verbose url resolving [ 'https://registry.npmjs.org/', './socket' ]
19 verbose url resolved https://registry.npmjs.org/socket
20 info trying registry request attempt 1 at 13:37:24
21 verbose etag "ECC2J4RYC4C159M60TQITIXSD"
22 http GET https://registry.npmjs.org/socket
23 http 304 https://registry.npmjs.org/socket
24 silly registry.get cb [ 304,
24 silly registry.get { server: 'CouchDB/1.3.1 (Erlang OTP/R15B03)',
24 silly registry.get etag: '"ECC2J4RYC4C159M60TQITIXSD"',
24 silly registry.get date: 'Fri, 06 Sep 2013 08:07:26 GMT',
24 silly registry.get 'content-length': '0' } ]
25 verbose etag socket from cache
26 silly addNameRange number 2 { name: 'socket', range: '*', hasData: true }
27 silly addNameRange versions [ 'socket', [ '0.0.1' ] ]
28 verbose addNamed [ 'socket', '0.0.1' ]
29 verbose addNamed [ '0.0.1', '0.0.1' ]
30 silly lockFile ccbb8590-socket-0-0-1 socket#0.0.1
31 verbose lock socket#0.0.1 C:\Users\cbaid\AppData\Roaming\npm-cache\ccbb8590-socket-0-0-1.lock
32 silly lockFile ccbb8590-socket-0-0-1 socket#0.0.1
33 silly lockFile ccbb8590-socket-0-0-1 socket#0.0.1
34 silly lockFile 45707214-socket socket#
35 silly lockFile 45707214-socket socket#
36 silly resolved [ { name: 'socket',
36 silly resolved description: 'Socket is a connect clone for simple socket based applications',
36 silly resolved version: '0.0.1',
36 silly resolved author:
36 silly resolved { name: 'Richard S Allinson',
36 silly resolved email: 'rsa#mounitainmansoftware.com' },
36 silly resolved main: 'index',
36 silly resolved engines: { node: '>= 0.6.0 < 0.7.0' },
36 silly resolved dependencies: { microtime: '=0.2.0' },
36 silly resolved repository: { type: 'git', url: 'https://github.com/capecodehq/socket.git' },
36 silly resolved license: 'MIT',
36 silly resolved bugs: { url: 'https://github.com/capecodehq/socket/issues' },
36 silly resolved readme: 'ERROR: No README data found!',
36 silly resolved _id: 'socket#0.0.1',
36 silly resolved _from: 'socket#' } ]
37 info install socket#0.0.1 into C:\NODEJS
38 info installOne socket#0.0.1
39 warn engine socket#0.0.1: wanted: {"node":">= 0.6.0 < 0.7.0"} (current: {"node":"v0.10.18","npm":"1.3.10"})
40 info C:\NODEJS\node_modules\socket unbuild
41 verbose tar unpack C:\Users\cbaid\AppData\Roaming\npm-cache\socket\0.0.1\package.tgz
42 silly lockFile aac0ba32-tar-C-NODEJS-node-modules-socket tar://C:\NODEJS\node_modules\socket
43 verbose lock tar://C:\NODEJS\node_modules\socket C:\Users\cbaid\AppData\Roaming\npm-cache\aac0ba32-tar-C-NODEJS-node-modules-socket.lock
44 silly lockFile 31f734a2-m-cache-socket-0-0-1-package-tgz tar://C:\Users\cbaid\AppData\Roaming\npm-cache\socket\0.0.1\package.tgz
45 verbose lock tar://C:\Users\cbaid\AppData\Roaming\npm-cache\socket\0.0.1\package.tgz C:\Users\cbaid\AppData\Roaming\npm-cache\31f734a2-m-cache-socket-0-0-1-package-tgz.lock
46 silly gunzTarPerm modes [ '755', '644' ]
47 silly gunzTarPerm extractEntry package.json
48 silly gunzTarPerm modified mode [ 'package.json', 438, 420 ]
49 silly gunzTarPerm extractEntry index.js
50 silly gunzTarPerm modified mode [ 'index.js', 438, 420 ]
51 silly gunzTarPerm extractEntry examples/echo-server.js
52 silly gunzTarPerm modified mode [ 'examples/echo-server.js', 438, 420 ]
53 silly gunzTarPerm extractEntry examples/simple-test.js
54 silly gunzTarPerm modified mode [ 'examples/simple-test.js', 438, 420 ]
55 silly gunzTarPerm extractEntry examples/simple-time-server.js
56 silly gunzTarPerm modified mode [ 'examples/simple-time-server.js', 438, 420 ]
57 silly gunzTarPerm extractEntry lib/index.js
58 silly gunzTarPerm modified mode [ 'lib/index.js', 438, 420 ]
59 silly gunzTarPerm extractEntry lib/proto.js
60 silly gunzTarPerm modified mode [ 'lib/proto.js', 438, 420 ]
61 silly gunzTarPerm extractEntry lib/utils.js
62 silly gunzTarPerm modified mode [ 'lib/utils.js', 438, 420 ]
63 silly gunzTarPerm extractEntry lib/middleware/echo.js
64 silly gunzTarPerm modified mode [ 'lib/middleware/echo.js', 438, 420 ]
65 silly gunzTarPerm extractEntry lib/middleware/errorHandler.js
66 silly gunzTarPerm modified mode [ 'lib/middleware/errorHandler.js', 438, 420 ]
67 silly gunzTarPerm extractEntry lib/middleware/json.js
68 silly gunzTarPerm modified mode [ 'lib/middleware/json.js', 438, 420 ]
69 silly gunzTarPerm extractEntry lib/middleware/profiler.js
70 silly gunzTarPerm modified mode [ 'lib/middleware/profiler.js', 438, 420 ]
71 silly gunzTarPerm extractEntry nbproject/private/private.properties
72 silly gunzTarPerm modified mode [ 'nbproject/private/private.properties', 438, 420 ]
73 silly gunzTarPerm extractEntry nbproject/project.properties
74 silly gunzTarPerm modified mode [ 'nbproject/project.properties', 438, 420 ]
75 silly gunzTarPerm extractEntry nbproject/project.xml
76 silly gunzTarPerm modified mode [ 'nbproject/project.xml', 438, 420 ]
77 silly gunzTarPerm extractEntry scripts/lint
78 silly gunzTarPerm modified mode [ 'scripts/lint', 438, 420 ]
79 silly lockFile aac0ba32-tar-C-NODEJS-node-modules-socket tar://C:\NODEJS\node_modules\socket
80 silly lockFile aac0ba32-tar-C-NODEJS-node-modules-socket tar://C:\NODEJS\node_modules\socket
81 silly lockFile 31f734a2-m-cache-socket-0-0-1-package-tgz tar://C:\Users\cbaid\AppData\Roaming\npm-cache\socket\0.0.1\package.tgz
82 silly lockFile 31f734a2-m-cache-socket-0-0-1-package-tgz tar://C:\Users\cbaid\AppData\Roaming\npm-cache\socket\0.0.1\package.tgz
83 info preinstall socket#0.0.1
84 verbose readDependencies using package.json deps
85 verbose readDependencies using package.json deps
86 verbose cache add [ 'microtime#=0.2.0', null ]
87 verbose cache add name=undefined spec="microtime#=0.2.0" args=["microtime#=0.2.0",null]
88 verbose parsed url { protocol: null,
88 verbose parsed url slashes: null,
88 verbose parsed url auth: null,
88 verbose parsed url host: null,
88 verbose parsed url port: null,
88 verbose parsed url hostname: null,
88 verbose parsed url hash: null,
88 verbose parsed url search: null,
88 verbose parsed url query: null,
88 verbose parsed url pathname: 'microtime#=0.2.0',
88 verbose parsed url path: 'microtime#=0.2.0',
88 verbose parsed url href: 'microtime#=0.2.0' }
89 verbose cache add name="microtime" spec="=0.2.0" args=["microtime","=0.2.0"]
90 verbose parsed url { protocol: null,
90 verbose parsed url slashes: null,
90 verbose parsed url auth: null,
90 verbose parsed url host: null,
90 verbose parsed url port: null,
90 verbose parsed url hostname: null,
90 verbose parsed url hash: null,
90 verbose parsed url search: null,
90 verbose parsed url query: null,
90 verbose parsed url pathname: '=0.2.0',
90 verbose parsed url path: '=0.2.0',
90 verbose parsed url href: '=0.2.0' }
91 verbose addNamed [ 'microtime', '=0.2.0' ]
92 verbose addNamed [ null, '=0.2.0' ]
93 silly lockFile 2e0a3709-microtime-0-2-0 microtime#=0.2.0
94 verbose lock microtime#=0.2.0 C:\Users\cbaid\AppData\Roaming\npm-cache\2e0a3709-microtime-0-2-0.lock
95 verbose url raw microtime/0.2.0
96 verbose url resolving [ 'https://registry.npmjs.org/', './microtime/0.2.0' ]
97 verbose url resolved https://registry.npmjs.org/microtime/0.2.0
98 info trying registry request attempt 1 at 13:37:26
99 verbose etag "83RCGGZ6LJDDFS0SFLQ3JN44H"
100 http GET https://registry.npmjs.org/microtime/0.2.0
101 http 304 https://registry.npmjs.org/microtime/0.2.0
102 silly registry.get cb [ 304,
102 silly registry.get { server: 'CouchDB/1.3.1 (Erlang OTP/R15B03)',
102 silly registry.get etag: '"83RCGGZ6LJDDFS0SFLQ3JN44H"',
102 silly registry.get date: 'Fri, 06 Sep 2013 08:07:28 GMT',
102 silly registry.get 'content-length': '0' } ]
103 verbose etag microtime/0.2.0 from cache
104 silly lockFile 2e0a3709-microtime-0-2-0 microtime#=0.2.0
105 silly lockFile 2e0a3709-microtime-0-2-0 microtime#=0.2.0
106 silly resolved [ { name: 'microtime',
106 silly resolved version: '0.2.0',
106 silly resolved description: 'Get the current time in microseconds',
106 silly resolved author:
106 silly resolved { name: 'Wade Simmons',
106 silly resolved email: 'wade#wades.im',
106 silly resolved url: 'http://wades.im/mons' },
106 silly resolved homepage: 'https://github.com/wadey/node-microtime',
106 silly resolved repository:
106 silly resolved { type: 'git',
106 silly resolved url: 'git://github.com/wadey/node-microtime.git' },
106 silly resolved main: './index',
106 silly resolved engines: { node: '>= 0.2.0' },
106 silly resolved scripts: { install: 'node-waf configure build', test: 'node test.js' },
106 silly resolved readme: '# node-microtime\n\nDate.now() will only give you accuracy in milliseconds. This module calls\n`gettimeofday(2)` to get the time in microseconds and provides it in a few\ndifferent formats. The same warning from that function applies:\n_The resolution of the system clock is hardware dependent, and the time may\nbe updated continuously or in ``ticks.\'\'_\n\n# Installation\n\n npm install microtime\n\n# Usage\n\n### microtime.now()\n\nGet the current time in microseconds as an integer. Since JavaScript can only\nrepresent integer values accurately up to `Math.pow(2, 53)`, this value will\nbe accurate up to _Tue, 05 Jun 2255 23:47:34 GMT_.\n\n### microtime.nowDouble()\n\nGet the current time in seconds as a floating point number with microsecond\naccuracy (similar to `time.time()` in Python and `Time.now.to_f` in Ruby).\n\n### microtime.nowStruct()\n\nGet the current time and return as a list with seconds and microseconds (matching the return value of `gettimeofday(2)`).\n\n# Example\n\n > var microtime = require(\'microtime\')\n > microtime.now()\n 1297448895297028\n > microtime.nowDouble()\n 1297448897.600976\n > microtime.nowStruct()\n [ 1297448902, 753875 ]\n\n## Estimating clock resolution\n\nStarting with version 0.1.3, there is a test script that tries to guess the clock resolution. You can run it with `npm test microtime`. Example output:\n\n microtime.now() = 1298960083489806\n microtime.nowDouble() = 1298960083.511521\n microtime.nowStruct() = [ 1298960083, 511587 ]\n\n Guessing clock resolution...\n Clock resolution observed: 1us\n\n## Tested on\n\n Node.js 0.2.6\n - OS X 10.6.6\n - Ubuntu 10.04\n\n Node.js 0.4.1\n - OS X 10.6.6\n - Windows 7 64bit (Cygwin) *\n\n## Warning for Cygwin users\n\nIt appears that Cygwin only implements `gettimeofday(2)` with [millisecond accuracy](http://old.nabble.com/gettimeofday---millisecond-accuracy-p21085475.html).\n',
106 silly resolved readmeFilename: 'README.md',
106 silly resolved bugs: { url: 'https://github.com/wadey/node-microtime/issues' },
106 silly resolved _id: 'microtime#0.2.0',
106 silly resolved _from: 'microtime#=0.2.0' } ]
107 info install microtime#0.2.0 into C:\NODEJS\node_modules\socket
108 info installOne microtime#0.2.0
109 info C:\NODEJS\node_modules\socket\node_modules\microtime unbuild
110 verbose tar unpack C:\Users\cbaid\AppData\Roaming\npm-cache\microtime\0.2.0\package.tgz
111 silly lockFile 4c47d62b-es-socket-node-modules-microtime tar://C:\NODEJS\node_modules\socket\node_modules\microtime
112 verbose lock tar://C:\NODEJS\node_modules\socket\node_modules\microtime C:\Users\cbaid\AppData\Roaming\npm-cache\4c47d62b-es-socket-node-modules-microtime.lock
113 silly lockFile 51b2e7ce-ache-microtime-0-2-0-package-tgz tar://C:\Users\cbaid\AppData\Roaming\npm-cache\microtime\0.2.0\package.tgz
114 verbose lock tar://C:\Users\cbaid\AppData\Roaming\npm-cache\microtime\0.2.0\package.tgz C:\Users\cbaid\AppData\Roaming\npm-cache\51b2e7ce-ache-microtime-0-2-0-package-tgz.lock
115 silly gunzTarPerm modes [ '755', '644' ]
116 silly gunzTarPerm extractEntry package.json
117 silly gunzTarPerm modified mode [ 'package.json', 438, 420 ]
118 silly gunzTarPerm extractEntry README.md
119 silly gunzTarPerm modified mode [ 'README.md', 438, 420 ]
120 silly gunzTarPerm extractEntry LICENSE
121 silly gunzTarPerm modified mode [ 'LICENSE', 438, 420 ]
122 silly gunzTarPerm extractEntry index.js
123 silly gunzTarPerm modified mode [ 'index.js', 438, 420 ]
124 silly gunzTarPerm extractEntry test.js
125 silly gunzTarPerm modified mode [ 'test.js', 438, 420 ]
126 silly gunzTarPerm extractEntry src/microtime.cc
127 silly gunzTarPerm modified mode [ 'src/microtime.cc', 438, 420 ]
128 silly gunzTarPerm extractEntry wscript
129 silly gunzTarPerm modified mode [ 'wscript', 438, 420 ]
130 silly lockFile 4c47d62b-es-socket-node-modules-microtime tar://C:\NODEJS\node_modules\socket\node_modules\microtime
131 silly lockFile 4c47d62b-es-socket-node-modules-microtime tar://C:\NODEJS\node_modules\socket\node_modules\microtime
132 silly lockFile 51b2e7ce-ache-microtime-0-2-0-package-tgz tar://C:\Users\cbaid\AppData\Roaming\npm-cache\microtime\0.2.0\package.tgz
133 silly lockFile 51b2e7ce-ache-microtime-0-2-0-package-tgz tar://C:\Users\cbaid\AppData\Roaming\npm-cache\microtime\0.2.0\package.tgz
134 info preinstall microtime#0.2.0
135 verbose readDependencies using package.json deps
136 verbose readDependencies using package.json deps
137 silly resolved []
138 verbose about to build C:\NODEJS\node_modules\socket\node_modules\microtime
139 info build C:\NODEJS\node_modules\socket\node_modules\microtime
140 verbose linkStuff [ false,
140 verbose linkStuff false,
140 verbose linkStuff false,
140 verbose linkStuff 'C:\\NODEJS\\node_modules\\socket\\node_modules' ]
141 info linkStuff microtime#0.2.0
142 verbose linkBins microtime#0.2.0
143 verbose linkMans microtime#0.2.0
144 verbose rebuildBundles microtime#0.2.0
145 info install microtime#0.2.0
146 verbose unsafe-perm in lifecycle true
147 error Error: spawn ENOENT
147 error at errnoException (child_process.js:980:11)
147 error at Process.ChildProcess._handle.onexit (child_process.js:771:34)
148 error If you need help, you may report this log at:
148 error <http://github.com/isaacs/npm/issues>
148 error or email it to:
148 error <npm-#googlegroups.com>
149 error System Windows_NT 6.1.7601
150 error command "C:\\NODEJS\\\\node.exe" "C:\\NODEJS\\node_modules\\npm\\bin\\npm-cli.js" "install" "socket"
151 error cwd C:\NODEJS
152 error node -v v0.10.18
153 error npm -v 1.3.10
154 error syscall spawn
155 error code ENOENT
156 error errno ENOENT
157 verbose exit [ 1, true ]
I have uninstalled and installed nodejs a lot many times. And even tried several methods by trying different methods mentioned by people on different posts. But nothing is working so far. Can somebody help?
I see this question is tagged as socket.io -- looks like you forgot the ".io" part of "socket.io". Try this:
npm install socket.io
As for explaining the error you see, the socket package is a pretty old package, the package.json says it only supports node v0.6 thru v0.7:
engines: { node: '>= 0.6.0 < 0.7.0' }
The root problem is that socket uses node-waf which was removed in node v0.8 (node-gyp is the replacement).

Resources