当我尝试安装节点软件包时出现zlib错误

时间:2019-07-31 22:06:01

标签: node.js sqlite npm electron

我在用以下命令进行npm install -g npm@latest的npm更新后,用npm安装新软件包时遇到问题,以解决与在电子应用程序的node_modules中安装sqlite3有关的问题。

但是,当我尝试运行sqlite3的命令:npm install sqlite3 --save或任何其他命令来安装新软件包时,会出现此错误:

npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar ENOENT: no such file or directory, chmod 'C:\Users\Ahmed\Desktop\Desktop_stuffs\workspace\terrains\Gestion Ecole\electron-quick-start\node_modules\.staging\sqlite3-2e42d809'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\Ahmed\Desktop\Desktop_stuffs\workspace\terrains\Gestion Ecole\electron-quick-start\node_modules\.staging\sax-8976b37c\lib\sax.js'
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN tar zlib: Cannot read property 'length' of null
npm WARN bootstrap@4.3.1 requires a peer of popper.js@^1.14.7 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.0.7 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: zlib: Cannot read property 'length' of null
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\rijs.resdir\node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: zlib: Cannot read property 'length' of null

npm ERR! zlib: Cannot read property 'length' of null

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Ahmed\AppData\Roaming\npm-cache\_logs\2019-07-31T22_03_39_222Z-debug.log

运行npm version会得出:

{'electron-quick-start': '1.0.0', 
npm: '6.10.2',                   
ares: '1.13.0',                  
cldr: '32.0',                    
http_parser: '2.7.0',            
icu: '60.1',                     
modules: '59',                   
nghttp2: '1.25.0',               
node: '9.2.0',                   
openssl: '1.0.2m',               
tz: '2017c',                     
unicode: '10.0',                 
uv: '1.16.1',                    
v8: '6.2.414.44-node.11',        
zlib: '1.2.11' }                 

1 个答案:

答案 0 :(得分:2)

我解决了这个问题,这只是npm与节点之间的兼容性问题,我使用了npm的最新版本和旧版本的节点,所以我只下载了节点的最新版本进行更新,并安装了命令正常运行。