I've been struggling the unknown parse error while building storybook.
I've been puzzled why it keeps happening.
It turned out that cache may have been corrupted and resulted with the error.
You could simply delete npm cache and node_modules
directory.
Error sample
I was experiencing the following error
[ssh@example.com]$ NODE_OPTIONS=--max_old_space_size=4096 yarn build-storybook:coding
yarn run v1.22.19
$ BASE_PATH=/storybook build-storybook -o dist/storybook
info @storybook/vue3 v6.5.10
info
info => Cleaning outputDir: /var/www/html/dist/storybook
info => Loading presets
info => Compiling manager..
ERR! => Failed to build the manager
ERR! Cannot parse records: Unexpected end of JSON input while parsing near ''
ERR! TypeError: previewBuilder.bail is not a function
ERR! at /var/www/html/node_modules/@storybook/core-server/dist/cjs/build-static.js:219:26
ERR! at processTicksAndRejections (node:internal/process/task_queues:96:5)
ERR! at async Promise.all (index 0)
ERR! at async buildStaticStandalone (/var/www/html/node_modules/@storybook/core-server/dist/cjs/build-static.js:218:28)
ERR! at async buildStatic (/var/www/html/node_modules/@storybook/core-server/dist/cjs/build-static.js:254:5)
ERR! TypeError: previewBuilder.bail is not a function
ERR! at /var/www/html/node_modules/@storybook/core-server/dist/cjs/build-static.js:219:26
ERR! at processTicksAndRejections (node:internal/process/task_queues:96:5)
ERR! at async Promise.all (index 0)
ERR! at async buildStaticStandalone (/var/www/html/node_modules/@storybook/core-server/dist/cjs/build-static.js:218:28)
ERR! at async buildStatic (/var/www/html/node_modules/@storybook/core-server/dist/cjs/build-static.js:254:5)
info => Loading presets
error Command failed with exit code 1.
So, the main error says
ERR! Cannot parse records: Unexpected end of JSON input while parsing near ''
STEP 1: Try to delete npm cache
Simply, let's try to run npm cache clear command
npm cache clean βforce
STEP 2: Try to delete node_modules/.cache
directory
If STEP 1 doesn't work, just try to delete the .cache
directory manually.
STEP 3: Try to delete node_modules
directory
Perhaps, there may be some conflict, so maybe you want to delete the entire node_modules
directory and rebuild.
STEP 4: Check installed node, npm, yarn versions
If you have multiple environments such as local, co-workers, and servers, and some environment worked but not the others, you may need to check the installed version of each environment.
After matching those, start over from STEP1.
Good luck.
References
https://www.danroo.com/web/post-666/
https://github.com/storybookjs/storybook/issues/4034#issuecomment-780694848
Top comments (0)