Problems to install Mocha: "Error Parsing Json" - json

I have a problem installing mocha. I try to install mocha with the following line:
npm install -g mocha
This is the output which I get (If I type the http://registry.npmjs.org/mocha into the browser I'm able to see the json data):
npm http GET http://registry.npmjs.org/mocha
npm http 404 http://registry.npmjs.org/mocha
npm ERR! registry error parsing json
npm ERR! SyntaxError: Unexpected token <
npm ERR! <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
npm ERR! <html><head>
npm ERR! <title>404 Not Found</title>
npm ERR! </head><body>
npm ERR! <h1>Not Found</h1>
npm ERR! <p>The requested URL /mocha was not found on this server.</p>
npm ERR! </body></html>
npm ERR!
npm ERR! at Object.parse (native)
npm ERR! at RegClient.<anonymous> (C:\Program Files\nodejs\node_modules\npm\
node_modules\npm-registry-client\lib\request.js:203:23)
npm ERR! at Request.self.callback (C:\Program Files\nodejs\node_modules\npm\
node_modules\request\request.js:123:22)
npm ERR! at Request.EventEmitter.emit (events.js:98:17)
npm ERR! at Request.<anonymous> (C:\Program Files\nodejs\node_modules\npm\no
de_modules\request\request.js:893:14)
npm ERR! at Request.EventEmitter.emit (events.js:117:20)
npm ERR! at IncomingMessage.<anonymous> (C:\Program Files\nodejs\node_module
s\npm\node_modules\request\request.js:844:12)
npm ERR! at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR! at _stream_readable.js:920:16
npm ERR! at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "mocha"
npm ERR! cwd C:\Users\myName
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! type unexpected_token
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\myName\npm-debug.log
npm ERR! not ok code 0

After hours trying to resolve this issue I found this solution:
The problem which I had is connected to the proxy settings of npm. Which means that npm was not able to load the json file correctly.
You have to set the proxy settings first:
npm config set proxy http://username:password#YourProxy:Port
npm config set https-proxy https://username:password#YourProxy:Port (If you have one)

Related

I am trying to deploy my MERN stack application on Heroku but I am getting following error

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /tmp/build_adf85737_/client/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_adf85737_/client/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.B4J9l/_logs/2021-01-29T15_45_48_832Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 254
npm ERR! server#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 254
npm ERR!
npm ERR! Failed at the server#1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.B4J9l/_logs/2021-01-29T15_45_48_856Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed

Artifactory npm publish failed PUT 404

I am trying to publish scoped npm packages to artifactory and I get the following error:
npm ERR! registry error parsing json
npm ERR! publish Failed PUT 404
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/Cellar/node4-lts/4.6.2/bin/node" "/usr/local/bin/npm" "publish"
npm ERR! node v4.6.2
npm ERR! npm v2.15.9
npm ERR! Unexpected token <
npm ERR! <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
npm ERR! <html><head>
npm ERR! <title>404 Not Found</title>
npm ERR! </head><body>
npm ERR! <h1>Not Found</h1>
npm ERR! <p>The requested URL /artifactory/api/npm/npm-local/#acres/acresmetajs was not found on this server.</p>
npm ERR! <hr>
npm ERR! <address>Apache/2.2.31 (Amazon) Server at artifacts.company.com Port 80</address>
npm ERR! </body></html>
I have set up my .npmrc file the following way:
registry=http://artifacts.company.com/artifactory/api/npm/npm-local/
_auth="mypassword"
always-auth=true
email=d.griner#company.com
#acres:registry=http://artifacts.company.com/artifactory/api/npm/npm-local/
//artifacts.company.com/artifactory/api/npm/npm-local/:_password=mypassword
//artifacts.company.com/artifactory/api/npm/npm-local/:username=myusername
//artifacts.company.com/artifactory/api/npm/npm-local/:email=d.griner#company.com
//artifacts.company.com/artifactory/api/npm/npm-local/:always-auth=true
I run npm publish and npm publish --registry http://artifacts.company.com/artifactory/api/npm/npm-local/ and get this same error. What am I missing?
I've found there are a couple more steps for getting scoped packages to work with artifactory if it's behind maven. https://techblog.dorogin.com/setting-up-artifactory-as-npm-repository-behind-apache-7541d5140492#.z0q412z5j
Essentially:
AllowEncodedSlashed set to NoDecode (by default it’s Off)
Added keyword nocanon for ProxyPass, it tells mod_proxy module not to canonicalize URLs
I got this on version 6.5.0. And the solution was remove "engines" group from in package.json.
npm ERR! publish Failed PUT 404
npm ERR! code E404
npm ERR! 404 NotFound The package 'xxxxxxxx' was not found in feed 'npmjs': xxxxxxxx
npm ERR! 404
npm ERR! 404 'xxxxxxxx' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

KOA - dependency for mysql error

I am a newbie to KOA framework, facing a issue while installing the mysql dependency using this command npm install knex-mysql-middleware on my windows xp machine. Below is the message i am getting on my console.
npm WARN package.json path#0.11.14 path is also the name of a node core module.
npm ERR! Error: ENOENT, chmod 'E:\testkoa\app3\node_modules\knex-mysql-middleware\node_modules\mysql\node_modules\readable-stream\node_modules\inherits\inherits.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 5.1.2600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "knex-mysql-middleware"
npm ERR! cwd E:\testkoa\app3
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path E:\testkoa\app3\node_modules\knex-mysql-middleware\node_modules\mysql\node_modules\readable-stream\node_modules\inherits\inherits.js
npm ERR! fstream_path E:\testkoa\app3\node_modules\knex-mysql-middleware\node_modules\mysql\node_modules\readable-stream\node_modules\inherits\inherits.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chmod
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:305:19
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: ENOENT, lstat 'E:\testkoa\app3\node_modules\knex-mysql-middleware\node_modules\mysql\node_modules\readable-stream\node_modules\core-util-is\float.patch'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
I've had a very similar problem before. You might try running:
npm cache clean
and see if that makes any difference.

Jhipster package.json issue in Mac

OS: 10.9.2
I am using jhipster generator, and it seems to be an issue with package.json in mac, do we have any work around?
Below is the error:
npm ERR! Error: ENOENT, utime '/Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/readable-stream/package.json'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/hmajumdar/Work/sandbox/jhipster
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! path /Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/readable-stream/package.json
npm ERR! fstream_path /Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/readable-stream/package.json
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call utimes
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:305:19
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: ENOENT, utime '/Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/inherits/package.json'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/hmajumdar/Work/sandbox/jhipster
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! path /Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/inherits/package.json
npm ERR! fstream_path /Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/inherits/package.json
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call utimes
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:305:19
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm http 304 https://registry.npmjs.org/promised-io
npm http GET https://registry.npmjs.org/win-spawn
npm ERR! Error: ENOENT, lstat '/Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/typedarray/package.json'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/hmajumdar/Work/sandbox/jhipster
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! path /Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/typedarray/package.json
npm ERR! fstream_path /Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/typedarray/package.json
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm http 304 https://registry.npmjs.org/uuid
npm http GET https://registry.npmjs.org/get-urls
npm http 304 https://registry.npmjs.org/astral-pass
npm http GET https://registry.npmjs.org/decompress
npm http GET https://registry.npmjs.org/get-stdin
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /Users/hmajumdar/.npm/tape/0.2.2/package/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/hmajumdar/Work/sandbox/jhipster
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! file /Users/hmajumdar/.npm/tape/0.2.2/package/package.json
npm ERR! code EJSONPARSE
npm http 304 https://registry.npmjs.org/win-spawn
npm http 304 https://registry.npmjs.org/get-urls
npm http 304 https://registry.npmjs.org/decompress
npm http 304 https://registry.npmjs.org/get-stdin
npm http GET https://registry.npmjs.org/object-keys
npm ERR! Error: ENOENT, lstat '/Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/output.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/hmajumdar/Work/sandbox/jhipster
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! path /Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/output.js
npm ERR! fstream_path /Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/output.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
1910 error error rolling back Error: ENOTEMPTY, rmdir '/Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-cssmin/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/inherits'
1910 error error rolling back grunt-contrib-cssmin#0.9.0 { [Error: ENOTEMPTY, rmdir '/Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-cssmin/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/inherits']
1910 error error rolling back errno: 53,
1910 error error rolling back code: 'ENOTEMPTY',
1910 error error rolling back path: '/Users/hmajumdar/Work/sandbox/jhipster/node_modules/grunt-contrib-cssmin/node_modules/maxmin/node_modules/gzip-size/node_modules/concat-stream/node_modules/inherits' }
1911 error Failed to parse json
1911 error Unexpected end of input
1912 error File: /Users/hmajumdar/.npm/tape/0.2.2/package/package.json
1913 error Failed to parse package.json data.
1913 error package.json must be actual JSON, not just JavaScript.
1913 error
1913 error This is not a bug in npm.
1913 error Tell the package author to fix their package.json file. JSON.parse
1914 error System Darwin 13.1.0
1915 error command "node" "/usr/local/bin/npm" "install"
1916 error cwd /Users/hmajumdar/Work/sandbox/jhipster
1917 error node -v v0.10.28
1918 error npm -v 1.4.9
1919 error file /Users/hmajumdar/.npm/tape/0.2.2/package/package.json
1920 error code EJSONPARSE
1921 verbose exit [ 1, true
I think it was due to the way NPM was being installed in my machine, I cleared some caches and reinstalled npm. That solved it.

Error in installing express either using package.json file or without using package.json file

I am trying to install express in my windows terminal by following the instruction mentioned in express website guide
1 First I created a directory node and inside that package.json file.
my package.json is as follows
{
"name": "hello-world",
"description": "hello world test app",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "3.x"
}
}
then I tried to run the command
npm install
but getting the following error
E:\myFindings\nodejs_programs\node>npm install
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express/-/express-3.4.8.tgz
npm ERR! Error: tunneling socket could not be established, cause=connect ETIMEDOUT
npm ERR! at ClientRequest.onError (C:\Program Files\nodejs\node_modules\npm\node_modules\request\tunnel.js:161:17)
npm ERR! at ClientRequest.g (events.js:185:14)
npm ERR! at ClientRequest.EventEmitter.emit (events.js:88:17)
npm ERR! at Socket.socketErrorListener (http.js:1320:9)
npm ERR! at Socket.EventEmitter.emit (events.js:88:17)
npm ERR! at Socket._destroy.self.errorEmitted (net.js:329:14)
npm ERR! at process.startup.processNextTick.process._tickCallback (node.js:244:9)
npm ERR! { [Error: tunneling socket could not be established, cause=connect ETIMEDOUT] code: 'ECONNRESET' }
npm ERR! You may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd E:\myFindings\nodejs_programs\node
npm ERR! node -v v0.8.0
npm ERR! npm -v 1.1.32
npm ERR! code ECONNRESET
npm ERR! message tunneling socket could not be established, cause=connect ETIMEDOUT
npm ERR! Error: socket hang up
npm ERR! at createHangUpError (http.js:1253:15)
npm ERR! at Socket.socketCloseListener (http.js:1304:23)
npm ERR! at Socket.EventEmitter.emit (events.js:88:17)
npm ERR! at Socket._destroy.destroyed (net.js:358:10)
npm ERR! at process.startup.processNextTick.process._tickCallback (node.js:244:9)
npm ERR! { [Error: socket hang up] code: 'ECONNRESET' }
npm ERR! You may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd E:\myFindings\nodejs_programs\node
npm ERR! node -v v0.8.0
npm ERR! npm -v 1.1.32
npm ERR! code ECONNRESET
npm ERR! message socket hang up
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! E:\myFindings\nodejs_programs\node\npm-debug.log
npm ERR! not ok code 0
I am unable to understand what is the problem, please help me to sort out
I even try to install express without using the .json file but getting the same error
contents of my npm config list
E:\myFindings\nodejs_programs\node>npm config list
; cli configs
; userconfig C:\Users\sudipkumars\.npmrc
https-proxy = "http://sudip:sudip7#proxy:8086/"
proxy = "http://sudip:sudip7#proxy:8086/%20strict-ssl%20=%20false"
registry = "https://registry.npmjs.org/"
; builtin config C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\sudipkumars\\AppData\\Roaming\\npm"
; node install prefix = C:\Program Files
; node bin location = C:\Program Files\nodejs\\node.exe
; cwd = E:\myFindings\nodejs_programs\node
; HOME = C:\Users\sudipkumars
; 'npm config ls -l' to show all defaults.
I tried your suggestion
npm config set registry http://registry.npmjs.org/
and output is
E:\myFindings\nodejs_programs\node>npm install express
npm http GET http://registry.npmjs.org/express
npm http 304 http://registry.npmjs.org/express
npm http GET http://registry.npmjs.org/express/-/express-3.4.8.tgz
npm ERR! Error: getaddrinfo ENOENT
npm ERR! at errnoException (dns.js:31:11)
npm ERR! at Object.onanswer [as oncomplete] (dns.js:123:16)
npm ERR! { [Error: getaddrinfo ENOENT] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }
npm ERR! You may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
In terms of understanding the issue. The problem lies with your computer not being able to establish a connection with: https://registry.npmjs.org/express/-/express-3.4.8.tgz
It is attempting to use the HTTP GET Method to retrieve the file from the server at the NPM registry but it seems it is timing out:
npm http GET https://registry.npmjs.org/express/-/express-3.4.8.tgz
npm ERR! Error: tunneling socket could not be established, cause=connect ETIMEDOUT
This could be for a few reasons but I'll mention two main causes:
Downtime at npmjs.org, easily checked with http://status.npmjs.org/
You're behind a proxy preventing this
Looking at your npm config:
Unless you have a proxy setup called proxy then this won't work. So clear the proxy variables set
Set strict SSL to false using npm config set strict-ssl false
If these two don't work, attempt to set the registry to use a non encrypted connection using npm config set registry http://registry.npmjs.org/
I solved this issue by issuing the following commands
npm config set proxy false
npm cache clean
run the following command
npm install express
work around: npm config set registry=http://registry.npmjs.org/ works well.