Unexpected end of json when installing npm package - html

Im trying to run npm install on ng2-smart-table. It looks like its having trouble getting some of the modules. Im getting the following error.
npm ERR! Unexpected end of JSON input while parsing near '..."spdy","version":"1.1'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/tommie/.npm/_logs/2018-05-15T14_32_04_066Z-debug.log
Tommies-MacBook-Pro:ng2-smart-table tommie$ vi /Users/tommie/.npm/_logs/2018-05-15T14_32_04_066Z-debug.log
Tommies-MacBook-Pro:ng2-smart-table tommie$ rm package-lock.json
rm: package-lock.json: No such file or directory
When I look at the log I get the following
<snip>
4508 silly pacote range manifest for http-proxy-middleware#~0.17.4 fetched in 16ms
4509 silly resolveWithNewModule http-proxy-middleware#0.17.4 checking installable status
4510 silly pacote version manifest for sockjs#0.3.18 fetched in 16ms
4511 silly resolveWithNewModule sockjs#0.3.18 checking installable status
4512 silly pacote version manifest for sockjs-client#1.1.2 fetched in 17ms
4513 silly resolveWithNewModule sockjs-client#1.1.2 checking installable status
4514 silly pacote range manifest for yargs#^6.0.0 fetched in 3ms
4515 silly resolveWithNewModule yargs#6.6.0 checking installable status
4516 http fetch GET 304 https://registry.npmjs.org/spdy 33ms (from cache)
4517 silly fetchPackageMetaData error for spdy#^3.4.1 Unexpected end of JSON input while parsing near '..."spdy","version":"1.1'
4518 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '..."spdy","version":"1.1'
4518 verbose stack at JSON.parse (<anonymous>)
4518 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)
4518 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)
4518 verbose stack at <anonymous>
4518 verbose stack at process._tickCallback (internal/process/next_tick.js:188:7)
4519 verbose cwd /Users/tommie/dev/ng2-smart-table
4520 verbose Darwin 15.6.0
4521 verbose argv "/usr/local/Cellar/node/8.2.1/bin/node" "/usr/local/bin/npm" "install"
4522 verbose node v8.2.1
4523 verbose npm v5.4.0
4524 error Unexpected end of JSON input while parsing near '..."spdy","version":"1.1'
4525 verbose exit [ 1, true ]
Any suggestions would be appreciated.

I got the same error and on searching I found out I needed to clear the npm cache first, did and it worked.
first run the following command:
npm cache clean --force
And then run that react-native command, it will work hopefully.

Related

How to pass the JSON validation of write-manifest.json when adding "debugLocale"?

I'm trying to build my first localised SPFX WebPart for Sharepoint Online. I've added an additional language de-de.js in the loc folder and now I'm trying to change the write-manifest.json to use my new language on debug by adding the `"debugLocale" property to it:
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->",
"debugLocale": "de-de"
}
Checking the official instructions of Microsoft and inspecting the JSON sheme of the write-manifest.json shows this should compile, but when I gulp serve it returns:
Build target: DEBUG
./node_modules/#microsoft/node-core-library/lib/JsonSchema.js:178
throw new Error(prefix + os.EOL +
^
Error: JSON validation failed:
./config/write-manifests.json
Error: #/ (Defines configuration options for the...)
Additional properties not allowed: debugLocale
at validateObjectWithCallback (./node_modules/#microsoft/node-core-library/lib/JsonSchema.js:178:19)
at JsonSchema.validateObjectWithCallback (./node_modules/#microsoft/node-core-library/lib/JsonSchema.js:193:13)
at JsonSchema.validateObject (./node_modules/#microsoft/node-core-library/lib/JsonSchema.js:175:14)
at WriteManifestsTask._readConfigFile (./node_modules/#microsoft/gulp-core-build/lib/tasks/GulpTask.js:311:28)
at WriteManifestsTask.onRegister (./node_modules/#microsoft/gulp-core-build/lib/tasks/GulpTask.js:87:32)
at Object.initialize (./node_modules/#microsoft/gulp-core-build/lib/index.js:299:24)
at SPWebBuildRig.initialize (./node_modules/#microsoft/sp-build-common/lib/BuildRig.js:61:19)
at SPWebBuildRig.initialize (./node_modules/#microsoft/sp-build-common/lib/SPBuildRig.js:29:15)
at SPWebBuildRig.initialize (./node_modules/#microsoft/sp-build-web/lib/SPWebBuildRig.js:15:15)
at Object.exports.initialize (./node_modules/#microsoft/sp-build-web/lib/index.js:23:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-world#0.0.1 start: `gulp serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world#0.0.1 start 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! ~/.npm/_logs/2019-01-09T16_43_53_070Z-debug.log
How can I solve this issue?
Between 1.5 and 1.6, the build tasks appeared to have changed. I have confirmed the issue with 1.6+.
If you modify your write-manfiest.json "debugLocale" to "buildSingleLocale", everything will work as expected. I think the docs and the schema may be out of date.
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->",
"buildSingleLocale": "de-de"
}
I just tried that and it works in my setup.
Created webpart using yo #microsoft/sharepoint with default options (using React as Javascript framework)
Added de-de.js file to loc folder and changed values so I can see that is really grabs the correct file
Added "debugLocale": "de-de" to write-manifests.json
Run gulp serve
Texts used are from de-de.js
My versions:
yo - 2.0.3
#microsoft/sharepoint generator - 1.4.1 (I know it is old one)
npm - 5.6.0 (Yes, also old one)
But, once I update the #microsoft/sharepoint generator to latest version 1.7.1 it stopped working. It seems that the issue occurs since version 1.6.0
Workaround is to run it with --locale parameter like gulp serve --locale=de-de or to use older version:
npm uninstall #microsoft/generator-sharepoint -g
npm install #microsoft/generator-sharepoint#1.5.1 -g

Click function in backstopjs not working while trying to log in using backstopjs

I am trying to log in to the system to navigate to the next page for visual test in backstopjs. For some reason I cannot perform click function as backstopjs doesn't detect my click command.
Following is the backstop.json snippet for the relevant action
{
"label": "Faethm Dashboard",
"cookiePath": "backstop_data/engine_scripts/cookies.json",
"url": "https://xxxxxx.com.au/dickyco",
"keyPressSelectors": [
{
"selector": "#email",
"keyPress": "Xxxxxxxxx#gmsil.com"
},
{
"selector": "#password",
"keyPress": "abcd!"
},
{
"selector":".ant-btn sc-kEYyzF hTZeXz",
"keyPress":"click()"
}
I get following error in my terminal
Puppeteer encountered an error while running scenario "Faethm Dashboard"
TimeoutError: waiting for selector "body.root " failed: timeout 30000ms exceeded
COMMAND | Executing core for "report"
compare | Reference image not found Test_Faethm_Dashboard_0__0_appleMacPro.png
compare | OK: Faethm Homepage Test_Faethm_Homepage_0_document_0_appleMacPro.png
report | Test completed...
report | 1 Passed
report | 1 Failed
report | Writing browser report
report | Resources copied
report | Copied configuration to: /Users/faethm/Desktop/VisualTest/backstopjs-example/backstop_data/html_report/config.js
COMMAND | Executing core for "openReport"
openReport | Attempting to ping
openReport | Remote not found. Opening backstop_data/html_report/index.html
report | *** Mismatch errors found ***
COMMAND | Command "report" ended with an error after [0.112s]
COMMAND | Error: Mismatch errors found.
at /Users/faethm/Desktop/VisualTest/backstopjs-example/node_modules/backstopjs/core/command/report.js:116:17
at process._tickCallback (internal/process/next_tick.js:68:7)
COMMAND | Command "test" ended with an error after [34.755s]
COMMAND | Error: Mismatch errors found.
at /Users/faethm/Desktop/VisualTest/backstopjs-example/node_modules/backstopjs/core/command/report.js:116:17
at process._tickCallback (internal/process/next_tick.js:68:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! backstopjs-example#1.0.0 test:visual: `rm -rf backstop_data/bitmaps_test && backstop test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the backstopjs-example#1.0.0 test:visual 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! /Users/faethm/.npm/_logs/2018-11-27T00_46_49_521Z-debug.log
Try removing your click from "keyPressSelectors" section, and using the built in clickSelector property after.
"clickSelector": ".ant-btn sc-kEYyzF hTZeXz"

MySQL XDevAPI crashes with "Queue is empty"

I left my development machine on overnight with the express server running and when I woke up I noticed the express server had crashed with the following error:
C:\Users\James\Projects\nine-tails\server\node_modules\#mysql\xdevapi\lib\WorkQueue.js:72
throw new Error('Queue is empty');
^
Error: Queue is empty
The error is coming from the xdevapi module but I can't seem to find anything on queues in the docs or why this error is happening.
Any advice?
Edit: Here's the entire log for the error:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\James\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'start:express' ]
2 info using npm#6.4.0
3 info using node#v10.8.0
4 verbose run-script [ 'prestart:express', 'start:express', 'poststart:express' ]
5 info lifecycle server#1.0.0~prestart:express: server#1.0.0
6 info lifecycle server#1.0.0~start:express: server#1.0.0
7 verbose lifecycle server#1.0.0~start:express: unsafe-perm in lifecycle true
8 verbose lifecycle server#1.0.0~start:express: PATH: C:\Users\James\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\James\Projects\nine-tails\server\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\James\bin;C:\Python37\Scripts;C:\Python37;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs;C:\Program Files\Git\cmd;C:\Program Files\PuTTY;C:\metasploit-framework\bin;C:\tools\php72;C:\Users\James\AppData\Local\Microsoft\WindowsApps;C:\Users\James\AppData\Roaming\npm;C:\Program Files\Docker Toolbox;C:\Users\James\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\James\AppData\Local\GitHubDesktop\bin
9 verbose lifecycle server#1.0.0~start:express: CWD: C:\Users\James\Projects\nine-tails\server
10 silly lifecycle server#1.0.0~start:express: Args: [ '/d /s /c',
10 silly lifecycle 'cross-env NODE_ENV=development DEBUG=express,database,routes node server.js' ]
11 silly lifecycle server#1.0.0~start:express: Returned: code: 1 signal: null
12 info lifecycle server#1.0.0~start:express: Failed to exec start:express script
13 verbose stack Error: server#1.0.0 start:express: `cross-env NODE_ENV=development DEBUG=express,database,routes node server.js`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Users\James\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\James\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:249:5)
14 verbose pkgid server#1.0.0
15 verbose cwd C:\Users\James\Projects\nine-tails\server
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\James\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "start:express"
18 verbose node v10.8.0
19 verbose npm v6.4.0
20 error code ELIFECYCLE
21 error errno 1
22 error server#1.0.0 start:express: `cross-env NODE_ENV=development DEBUG=express,database,routes node server.js`
22 error Exit status 1
23 error Failed at the server#1.0.0 start:express script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
and
C:\Users\James\Projects\nine-tails\server\node_modules\#mysql\xdevapi\lib\WorkQueue.js:72
throw new Error('Queue is empty');
^
Error: Queue is empty
at WorkQueue.process (C:\Users\James\Projects\nine-tails\server\node_modules\#mysql\xdevapi\lib\WorkQueue.js:72:15)
at Client.handleServerMessage (C:\Users\James\Projects\nine-tails\server\node_modules\#mysql\xdevapi\lib\Protocol\Client.js:201:21)
at Client.handleNetworkFragment (C:\Users\James\Projects\nine-tails\server\node_modules\#mysql\xdevapi\lib\Protocol\Client.js:245:14)
at TLSSocket.stream.on.data (C:\Users\James\Projects\nine-tails\server\node_modules\#mysql\xdevapi\lib\Protocol\Client.js:65:36)
at TLSSocket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at TLSSocket.Readable.push (_stream_readable.js:219:10)
at TLSWrap.onread (net.js:639:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server#1.0.0 start:express: `cross-env NODE_ENV=development DEBUG=express,database,routes node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server#1.0.0 start:express 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! C:\Users\James\AppData\Roaming\npm-cache\_logs\2018-09-05T09_06_40_255Z-debug.log
Shouldn't be happening, unless the X Plugin (MySQL server) is sending some out-of-band or unexpected message (which would be pretty weird).
Anyway, that's not a lot to work with. Maybe you can extend your logging infrastructure (or mess a bit with the response handlers in the connector) too see what's actually happening.
If you find something interesting, I suggest you create a bug report in the official MySQL issue tracker using the Connector for Node.js category.
Disclaimer: I'm the project lead dev.

NetLify CMS - gulpe server error due to missing ./bin/hugo.win32 file

I am testing NetLify CMS for a project, but I am not able to work in my local environment, because gulp server crashs before it start, due to the error below:
$ npm start
> victor-hugo#1.0.0 start C:\Users\maufa\Documents\web-development\kaldi-hugo-cms-template
> gulp server
[14:17:07] Requiring external module babel-register
[14:17:08] Using gulpfile ~\Documents\web-development\kaldi-hugo-cms-template\gulpfile.babel.js
[14:17:08] Starting 'hugo'...
[14:17:08] Starting 'css'...
[14:17:09] Starting 'js'...
[14:17:09] Starting 'svg'...
[14:17:09] Starting 'cms'...
[14:17:09] Finished 'cms' after 150 ms
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn ./bin/hugo.win32 ENOENT
at exports._errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! victor-hugo#1.0.0 start: `gulp server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the victor-hugo#1.0.0 start script 'gulp server'.
So, looks like it is trying to find hugo.win32 inside the bin folder.
However, inside this folder I ave:
hugo.darwin
hugo.exe
hugo.linux
Any clue?
It looks like this issue is particular to the Kaldi Hugo template. I installed on Windows and got the same error, then I tried renaming hugo.exe to hugo.win32, and it worked. I found the error in gulpfile.babel.js (incorrect string identifier for Windows), and submitted a PR. If you don't want to wait for the merge, feel free to change your version directly: https://github.com/netlify-templates/kaldi-hugo-cms-template/pull/3/files

error installing dependencies from package.json

I just downloaded node.js and I'm trying to install a couple of dependencies from package.json, and I keep getting the same error. I tryied the latest version and the LTS, and both gave the same error.
package.json
{
"name": "snake-ch3",
"dependencies": {
"express": "*",
"express-generator": "*"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-browserify": "~3.4.0",
"grunt-contrib-uglify": "~0.8.0",
"grunt-contrib-watch": "~0.6.1"
}
}
and 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' ]
2 info using npm#2.15.9
3 info using node#v4.6.0
4 verbose readDependencies loading dependencies from C:\Users\Julian\Desktop\node\ch3\package.json
5 error install Couldn't read dependencies
6 verbose stack Error: Failed to parse json
6 verbose stack No data, empty input at 1:1
6 verbose stack
6 verbose stack ^
6 verbose stack at parseError (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:390:11)
6 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:79:23)
6 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:48:5
6 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16
6 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
7 verbose cwd C:\Users\Julian\Desktop\node\ch3
8 error Windows_NT 10.0.14393
9 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
10 error node v4.6.0
11 error npm v2.15.9
12 error file C:\Users\Julian\Desktop\node\ch3\package.json
13 error code EJSONPARSE
14 error Failed to parse json
14 error No data, empty input at 1:1
14 error
14 error ^
15 error File: C:\Users\Julian\Desktop\node\ch3\package.json
16 error Failed to parse package.json data.
16 error package.json must be actual JSON, not just JavaScript.
16 error
16 error This is not a bug in npm.
16 error Tell the package author to fix their package.json file. JSON.parse
17 verbose exit [ 1, true ]
I validated the json on https://jsonformatter.curiousconcept.com/ and looked for json parsing errors related to "Windows_NT 10.0.14393" and I'm not getting anything.
I reinstalled node a couple of times so it's not node, or a dowloading problem. Can anyone tell me if I'm doing anything wrong?
EDIT
I just tryied running npm init with all of the default values and then editing it so it has the "dependencies" and "devDependencies" and it works all of a sudden. I tryied doing it again the way I did it before, and I got the same error.
now it looks like this:
package.json
{
"name": "snake-game",
"version": "1.0.0",
"description": "a simple snake game",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Julian Avar",
"dependencies": {
"express": "*",
"express-generator": "*"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-browserify": "~3.4.0",
"grunt-contrib-uglify": "~0.8.0",
"grunt-contrib-watch": "~0.6.1"
}
}
I've noticed that files made in many Windows programs will often prepend the text with bytes in a way that will prevent Unix based programs from reading them correctly (esp if the Unix program is expecting a structure like a JSON file). From #robertklep's comment, I assume it's a Byte Order Mark, but I've never known the name for it before now.
The recommended way to make a package.json to avoid this kind of thing is to run npm init from your command line, to both avoid OS wonkiness and also to make sure you have a minimally valid package.json when all is said and done.