I'm trying to run npm install and I get this:
root#WF-DEV1:/var/www/laravel# npm install
npm ERR! install Couldn't read dependencies
npm ERR! Failed to parse json
npm ERR! Unexpected token }
npm ERR! File: /var/www/laravel/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
This is my package.json file:
{
"name": "bootstrap-tagsinput",
"title": "Bootstrap Tags Input",
"version": "0.5.0",
"description": "jQuery plugin providing a Twitter Bootstrap user interface for managing tags.",
"scripts": {
"test": "karma start --single-run --no-auto-watch"
},
"main" : "dist/bootstrap-tagsinput.js",
"repository": {
"type": "git",
"url": "git://github.com/timschlechter/bootstrap-tagsinput.git"
},
"author": "Tim Schlechter",
"contributors": [{
"name": "Luckner Jr Jean-Baptiste"
}],
"license": "MIT",
"homepage": "http://timschlechter.github.io/bootstrap-tagsinput/examples/",
"download": "http://timschlechter.github.io/bootstrap-tagsinput/build/bootstrap-tagsinput.zip",
"keywords": [
"tags",
"bootstrap",
"input",
"select",
"form"
],
"readmeFilename": "README.md",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-cli": "~0.1.13",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-jquerymanifest": "~0.1.4",
"grunt-zip": "~0.15.0",
"karma": "~0.12.19",
"phantomjs": "~1.9.7-15",
"karma-phantomjs-launcher": "~0.1.3",
"karma-jasmine": "~0.1.5",
"grunt-karma": "~0.8.3",
"bower": "~1.3.8",
"grunt-bower-task": "~0.4.0"
},
"banner": "/*\n * <%= pkg.name %> v<%= pkg.version %> by <%= pkg.author %>\n * <%= pkg.license.url %>\n */\n"
}
Any help would be appreciated!
The JSON appears to be valid (I ran it through an online parser). I ran the same package.json under windows and got the following output:
D:\workspace\deleteme>npm install
npm ERR! install Couldn't read dependencies
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.1.1
npm ERR! npm v2.14.4
npm ERR! file D:\workspace\deleteme\package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected token '<' at 1:1
npm ERR! <!DOCTYPE html>
npm ERR! ^
npm ERR! File: D:\workspace\deleteme\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! Please include the following file with any support request:
npm ERR! D:\workspace\deleteme\npm-debug.log
The npm-debug.log started with:
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.14.4
3 info using node#v4.1.1
4 verbose readDependencies loading dependencies from D:\workspace\deleteme\package.json
5 error install Couldn't read dependencies
6 verbose stack Error: Failed to parse json
6 verbose stack Unexpected token '<' at 1:1
6 verbose stack <!DOCTYPE html>
6 verbose stack ^
6 verbose stack at parseError (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:379:11)
6 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:68: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:76:16
6 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
7 verbose cwd D:\workspace\deleteme
So on a hunch, I changed your devDependencies to dependencies and that worked. So I don't have a firm answer, but it seems there is definitely something in your file that npm has a problem with - it's just not a JSON error.
For some reason, the wrong code was in my package.json. Not sure how it got there but I definitely didn't put it there. I reinstalled everything and it's now fixed and the right code is in there now.
Related
After bumping the node version on my Firebase project from node 10 to node 14 in my package.json, like so:
...
"engines": {
"node": "14"
},
...
Firebase throws an error whenever I try to deploy a function.
First, I run:
firebase deploy --only functions:foo
Afterwards, the console shows:
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> lint
> gts lint
version: 14
Running command: npm --prefix "$RESOURCE_DIR" run build
> build
> ttsc
✔ functions: Finished running predeploy script.
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔ functions: required API cloudbuild.googleapis.com is enabled
✔ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (257.54 KB) for uploading
i pubsub: ensuring required API pubsub.googleapis.com is enabled...
i scheduler: ensuring required API cloudscheduler.googleapis.com is enabled...
✔ pubsub: required API pubsub.googleapis.com is enabled
✔ scheduler: required API cloudscheduler.googleapis.com is enabled
✔ functions: functions folder uploaded successfully
i functions: updating Node.js 14 function foo(us-central1)...
✔ functions[foo(us-central1)]: Successful upsert schedule operation.
Functions deploy had errors with the following functions:
foo(us-central1)
To try redeploying those functions, run:
firebase deploy --only "functions:foo"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Unfortunately, there's not much logs that I can get from the error:
By running:
firebase deploy --only functions:foo
I get the following error logs:
{"code":3,"message":"Build failed: > sharp#0.28.3 install /workspace/node_modules/sharp\n> (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)\n\nsharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.6/libvips-8.10.6-linux-x64.tar.br\n\n> protobufjs#6.10.2 postinstall /workspace/node_modules/protobufjs\n> node scripts/postinstall\n\n\n> functions#undefined prepare /workspace\n> npm run compile\n\n\n> functions# compile /workspace\n> ttsc\n\nsh: 1: ttsc: not found\nnpm ERR! code ELIFECYCLE\nnpm ERR! syscall spawn\nnpm ERR! file sh\nnpm ERR! errno ENOENT\nnpm ERR! functions# compile: ttsc\nnpm ERR! spawn ENOENT\nnpm ERR! \nnpm ERR! Failed at the functions# compile script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_cacache/_logs/2021-06-06T04_27_25_637Z-debug.log\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! functions#undefined prepare: npm run compile\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the functions#undefined prepare script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_logs/2021-06-06T04_27_25_673Z-debug.log; Error ID: beaf8772"}
In addition, my node version is:
node --version
v14.17.0
After looking at the Cloud Build from the Google Cloud Console, I've noticed that the following error:
2021-06-07T03:28:00.714478581ZStep #4 - "builder": src/cloud_functions/userInfo/https/onCall/uploadAvatar.ts(4,19): error TS7016: Could not find a declaration file for module 'sharp'. '/workspace/node_modules/sharp/lib/index.js' implicitly has an 'any' type.
To fix this, I simply added the following code in the tsconfig.json:
{
"compilerOptions": {
"noImplicitAny": false,
...
},
...
}
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.
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
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.
I'm using this tutorial to understand implementing oauth2 in Node.js.
This is my package.json:
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "coffee -w server.coffee"
},
"dependencies": {
"express": "3.3.4",
"jade": "*",
"coffee-script": "latest",
"passport-http": "latest",
"passport-http-bearer": "latest",
"passport-oauth2-client-password": "latest",
"oauth2orize": "latest",
"debug" "~0.7.2"
}
}
I'm getting the error:
npm ERR! install Couldn't read dependencies
npm ERR! Failed to parse json
npm ERR! Unexpected string
npm ERR! File: /Users/jashua/Desktop/auth/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 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/jashua/Desktop/auth
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.3.5
npm ERR! file /Users/jashua/Desktop/auth/package.json
npm ERR! code EJSONPARSE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/me/Desktop/auth/npm-debug.log
npm ERR! not ok code 0
Any ideas what's wrong with my package.json?
The error means exactly what it states, the JSON in your package.json is not valid and can't be parsed properly. Change "debug" "~0.7.2" to "debug": "~0.7.2".
Use this command to fix package.json related issue.
npm cache clean
C:\Program Files\nodejs>npm cache verify
Fixes it on Windows 10, run it with an Administrator command prompt Window.
I arrived at this page due to the same npm error, but a different cause. After viewing the log files, I realized that npm did not like my comment on the top line of the file.
// package.json
{ ...
}
After removing all comments, npm ran through everything beautifully. My comment was not necessary, so I'm fine as it is. But if you require comments within your xml, see How do I add comments to package.json for npm install?
I had the same issue caused by changes that I had made to my package.json file. I just reverted to my backup version of the package.json file. I attached that below if anyone else needs one:
{"name": "OpenShift-Sample-App",
"version": "1.0.0",
"description": "OpenShift Sample Application",
"keywords": [
"OpenShift",
"Node.js",
"application",
"openshift"
],
"author": {
"name": "OpenShift",
"email": "ramr#example.org",
"url": "http://www.openshift.com/"
},
"homepage": "http://www.openshift.com/",
"repository": {
"type": "git",
"url": "https://github.com/openshift/origin-server"
},
"engines": {
"node": ">= 0.6.0",
"npm": ">= 1.0.0"
},
"dependencies": {
"express": "~3.4.4"
},
"devDependencies": {},
"bundleDependencies": [],
"private": true,
"main": "server.js"
}
Sometimes you might have some weird unicode chars in your package.json. For example you might have \u00A0 (unicode non-breaking space) instead of a space somewhere. It looks the same in editor, so beware.
(I just had such problem after copying a small piece of config from a blog.)
My project was in D:\wwwroot\Projetos 2017\Android\PluginTest\PluginTest\plugins\cordova-plugin-iservice
The problem is space between Projetos(here)2017
I removed space to:
D:\wwwroot\Projetos2017\Android\PluginTest\PluginTest\plugins\cordova-plugin-iservice
and Work fine