npm ERR! Unexpected end of JSON input while parsing near

npm安装module时报错

C:\Users\80022319\Desktop\node\openfaas>npm install express -g
npm ERR! Unexpected end of JSON input while parsing near '...t":"^1.1.0","mkdirp":'

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\software\dev\node\node_cache\_logs\2020-12-29T05_51_48_634Z-debug.log

解决

  1. npm cache clean --force

    C:\Users\80022319\Desktop\node\openfaas>npm cache clean --force
    npm WARN using --force I sure hope you know what you are doing.
    
  2. npm cache verify

    C:\Users\80022319\Desktop\node\openfaas>npm cache verify
    Cache verified and compressed (D:\software\dev\node\node_cache\_cacache):
    Content verified: 63 (801482 bytes)
    Index entries: 91
    Finished in 0.272s
    
  3. npm install

    C:\Users\80022319\Desktop\node\openfaas>npm install
    npm WARN deprecated undefined@0.1.0: this package has been deprecated
    npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\80022319\Desktop\node\package.json'
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\80022319\Desktop\node\package.json'
    npm WARN node No description
    npm WARN node No repository field.
    npm WARN node No README data
    npm WARN node No license field.
    
    removed 2 packages in 11.817s
    found 0 vulnerabilities
    
  4. npm install -g express

    C:\Users\80022319\Desktop\node\openfaas>npm install -g express
    + express@4.17.1
    added 50 packages from 37 contributors in 136.893s
    

Guess you like

Origin blog.csdn.net/qq_30038111/article/details/112445272