Today, I removed node_modules and re-tried NPM Run Install with the following error:
npm ERR! Unexpected end of JSON input while parsing near '...l.com"}],"directories'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/louyanping/.npm/_logs/2018-12-14T03_32_00_994Z-debug.log
louyanpingdeMacBook-Pro:cnpc_group_buying louyanping$
Remember that this error has occurred before, and then I do a search, and find the solution, which is to execute NPM cache clean --force (if this still doesn't work for some people, just delete package-lock.json and try again).
So the question is, why does this happen?
Take a look at how NPM Install works:
- issue the NPM install command NPM downloads the compressed package from the registry’s url, and store it in ~/. NPM (local NPM cache path) directory to unzip the compressed package to the node_modules directory
of the current project
In fact, when a module is installed, two copies are saved locally. One is the compressed package in ~/.npm and the other is the unzipped code in node_modules. However, when you run NPM install, it only checks the node_modules directory, not the ~/.npm directory. If a module has a zip package under ~./ NPM but not installed in the node_modules directory, NPM will still download a new zip package from the remote repository.
The cache mechanism that we want to implement offline module installation using modules that have been previously backed up in the cache has been overwritten in V5. The cache will be maintained globally by NPM and the developer will no longer have to worry about it. The offline installation will no longer attempt to connect to the network, but the degraded attempt to read from the cache or fail. If you offline, NPM will use your cache seamlessly.
But, in fact, After watching all this, I still feel overwhelmed… Still checked some information, but can only find that:
this is a problem with the NPM cache corruption. Although they have self-repaired in newer versions of NPM, which is usually guaranteed to be corruption-free, it doesn’t seem to work that well.
, where a Forcing clean cache could solve a similar problem.
An error occurred while parsing one of the JSON-formatted cache files. Cache found in ~/.npm/_cacache (in Linux) and %AppData%/ nPm-Cache (in Windows). PS: For my current NPM release, when I check, there are 3 directories.
If you continue to view the first or second file, the structure looks like this:
Each cache file has a json format
This led to speculation that the files might have gone wrong when the cache was re-installed, a so-called cache corruption problem. (Welcome to correct, according to the data really can not find the exact specific reason!)
Read More:
- Error: Cannot find module ‘process-nextick-args’
- NPM report error: eperm: operation not permitted, unlink… Solution and clear cache_ modules
- Cannot find module ‘lodash’
- Some mistakes in using NPM
- Error reported after moving or copying Vue items: cannot find module ‘xxx‘
- The solution of NPM err! Code elifecycle
- Node.js Cannot find module ‘mysql’ ‘express’
- Vue project startup error: cannot find module XXX
- Error: EPERM: operation not permitted, mkdir ‘D:\nodejs\node_modules\npm\node_cache\_npx‘
- NPM- Cannot find module ‘xxxxx’
- Cannot find module ‘internal / util / types’ appears during gulp build
- Error “NPM err” when starting Vue project! code ELIFECYCLE”
- Failed to load plugin jsdoc: Cannot find module ‘eslint-plugin-jsdoc‘
- Error: Cannot find module ‘webpack/schemas/WebpackOptions.json’
- npm ERR! Error: CERT_ Untrusted problem solving
- Gulp failed to run
- UnhandledPromiseRejectionWarning Error: Can‘t set headers after they are sent (How to Fix)
- mac Error: EACCES: permission denied, mkdir ‘./cache’
- Error: EBUSY: resource busy or locked
- npm run devstart error: Error: Unable to find module ‘semver’