Bluebird: stack SyntaxError: Unexpected string in JSON at position 493

Created on 5 Feb 2018  路  6Comments  路  Source: petkaantonov/bluebird

(This issue tracker is only for bug reports or feature requests, if this is neither, please choose appropriate channel from http://bluebirdjs.com/docs/support.html)

Please answer the questions the best you can:

1) What version of bluebird is the issue happening on?
Not sure because it's not showing up in npm list

2) What platform and version? (For example Node.js 0.12 or Google Chrome 32)
node v9.5.0

3) Did this issue happen with earlier version of bluebird?
I've never explicitly used bluebird, I believe it was installed as a dependency for Babel on my system.
There seems to be an error in the bluebird module which is preventing my npm install from working. Error:

14 verbose stack SyntaxError: Unexpected string in JSON at position 493
14 verbose stack     at JSON.parse (<anonymous>)
14 verbose stack     at module.exports (/usr/local/lib/node_modules/npm/lib/utils/parse-json.js:3:15)
14 verbose stack     at BB.join (/usr/local/lib/node_modules/npm/lib/install/read-shrinkwrap.js:31:20)
14 verbose stack     at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
14 verbose stack     at Holder$3._callFunction (eval at generateHolderClass (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/join.js:92:16), <anonymous>:14:44)
14 verbose stack     at Holder$3.checkFulfillment (eval at generateHolderClass (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/join.js:92:16), <anonymous>:29:30)
14 verbose stack     at Promise.eval (eval at thenCallback (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/join.js:14:16), <anonymous>:6:20)
14 verbose stack     at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:566:21)
14 verbose stack     at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
14 verbose stack     at Promise._settlePromises (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
14 verbose stack     at Promise._fulfill (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:638:18)
14 verbose stack     at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:582:21)
14 verbose stack     at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
14 verbose stack     at Promise._settlePromises (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
14 verbose stack     at Promise._fulfill (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:638:18)
14 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/nodeback.js:42:21
15 verbose cwd <app-path>
16 verbose Darwin 17.3.0
17 verbose argv "/usr/local/Cellar/node/9.5.0/bin/node" "/usr/local/bin/npm" "install"
18 verbose node v9.5.0
19 verbose npm  v5.6.0
20 error Unexpected string in JSON at position 493
21 verbose exit [ 1, true ]

I can't just fix this issue on my local as I don't upload my node_modules on Github and this error doesn't seem to be coming up on any other system

Most helpful comment

Yeah, I just figured out that this was due to an invalid package-lock.json file. I deleted said file and re-ran npm install and now everything is working as expected.

All 6 comments

I'm getting something very similar:

13 silly saveTree `-- [email protected]
14 verbose stack SyntaxError: Unexpected string in JSON at position 37411
14 verbose stack     at JSON.parse (<anonymous>)
14 verbose stack     at module.exports (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\lib\utils\parse-json.js:3:15)
14 verbose stack     at BB.join (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\lib\install\read-shrinkwrap.js:31:20)
14 verbose stack     at tryCatcher (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
14 verbose stack     at Holder$3._callFunction (eval at generateHolderClass (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), <anonymous>:14:44)
14 verbose stack     at Holder$3.checkFulfillment (eval at generateHolderClass (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), <anonymous>:29:30)
14 verbose stack     at Promise.eval (eval at thenCallback (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\join.js:14:16), <anonymous>:6:20)
14 verbose stack     at Promise._settlePromise (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\promise.js:566:21)
14 verbose stack     at Promise._settlePromise0 (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
14 verbose stack     at Promise._settlePromises (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
14 verbose stack     at Promise._fulfill (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
14 verbose stack     at Promise._settlePromise (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\promise.js:582:21)
14 verbose stack     at Promise._settlePromise0 (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
14 verbose stack     at Promise._settlePromises (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
14 verbose stack     at Promise._fulfill (C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
14 verbose stack     at C:\Users\Administrator\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release\nodeback.js:42:21
15 verbose cwd C:\BuildAgent\work\25228993f9712156\web\source\Ai.web.site
16 verbose Windows_NT 10.0.14393
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
18 verbose node v8.9.4
19 verbose npm  v5.6.0
20 error Unexpected string in JSON at position 37411

This is using node v8.9.4, npm v5.6.0, running on Windows 10 Pro

You have invalid JSON somewhere - this isn't related to bluebird and is a bug in some library using bluebird. You can see which in the node-modules (looks like read-shrinkwrap in NPM?).

Bluebird might be able to help you further if you turn on the environment flag for long stack traces.

Yeah, I just figured out that this was due to an invalid package-lock.json file. I deleted said file and re-ran npm install and now everything is working as expected.

Same issue for me, it turned out to be a third party library which was breaking it.

similar issue for me, just remove package-lock.json,then it works fine!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rainabba picture rainabba  路  5Comments

chrisprobst picture chrisprobst  路  5Comments

ctrlplusb picture ctrlplusb  路  3Comments

icodeforlove picture icodeforlove  路  3Comments

jefflewis picture jefflewis  路  6Comments