简体   繁体   English

npm启动失败,因为缺少模块'minizlib'

[英]Failed npm start because of missing module 'minizlib'

I cloned a react-native project from github to work on, but npm start fails and reads this: 我从github克隆了一个react-native项目进行工作,但是npm start失败并显示以下内容:

Error: Cannot find module 'minizlib'
Require stack:
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/pack.js
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/create.js
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/index.js
- /usr/local/lib/node_modules/expo-cli/node_modules/@expo/xdl/build/Extract.js
- /usr/local/lib/node_modules/expo-cli/node_modules/@expo/xdl/build/Api.js
- /usr/local/lib/node_modules/expo-cli/node_modules/@expo/xdl/build/xdl.js
- /usr/local/lib/node_modules/expo-cli/build/exp.js
- /usr/local/lib/node_modules/expo-cli/bin/expo.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Module.require (internal/modules/cjs/loader.js:683:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/pack.js:28:14)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:683:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `expo start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/yeastbeast/.npm/_logs/2019-07-07T13_59_02_331Z-debug.log

Here is the debug log file: 这是调试日志文件:

1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.9.0
3 info using node@v12.6.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @~prestart: @
6 info lifecycle @~start: @
7 verbose lifecycle @~start: unsafe-perm in lifecycle true
8 verbose lifecycle @~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/geoffrey/mhs-protect/node_modules/.bin:/home/geoffrey/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle @~start: CWD: /home/geoffrey/mhs-protect
10 silly lifecycle @~start: Args: [ '-c', 'expo start' ]
11 silly lifecycle @~start: Returned: code: 1  signal: null
12 info lifecycle @~start: Failed to exec start script
13 verbose stack Error: @ start: `expo start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:203:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:203:13)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid @
15 verbose cwd /home/geoffrey/mhs-protect
16 verbose Linux 4.18.0-25-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v12.6.0
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ start: `expo start`
22 error Exit status 1
23 error Failed at the @ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I have tried installing and reinstalling minizlib, npm, and node, and also a handful of possible solutions found in similar questions here, but have had no success. 我尝试安装和重新安装minizlib,npm和node,以及在此处类似问题中发现的少数几种可能的解决方案,但均未成功。 Any help would be appreciated. 任何帮助,将不胜感激。

Os: Ubuntu 18.04.2 操作系统:Ubuntu 18.04.2

link to github repo 链接到github repo

Edit: I'm not quite sure what happened but it does seem to working. 编辑:我不太确定发生了什么,但似乎确实起作用。 I opened the project today to see if anything changed and received some warnings about vulnerabilities. 我今天打开了该项目,以查看是否有任何更改并收到有关该漏洞的一些警告。 To fix them i reinstalled expo-cli and now all seems to be working correctly. 为了修复它们,我重新安装了expo-cli,现在似乎一切正常。

npm install -g npm@latest (to update npm). npm install -g npm@latest (更新npm)。

rm -rf node_modules (to remove the existing modules). rm -rf node_modules (删除现有模块)。

npm install (to re-install the project dependencies). npm install (重新安装项目依赖项)。

Your package.json files contains this, 您的package.json文件包含此文件,

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject"
  },
  "dependencies": {
    "braces": "^2.3.1",
    "expo": "^32.0.0",
    "firebase": "^6.1.0",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
    "react-navigation": "^3.11.0",
    "ws": "^3.3.3"
  },
  "devDependencies": {
    "babel-preset-expo": "^5.0.0"
  },
  "private": true
}

package.json file don't have entry for minizlib package. package.json文件没有minizlib软件包的条目。 Also node_modules folder don't have minizlib folder. 另外, node_modules文件夹没有minizlib文件夹。

Probably missing to install the same, you can do this, 可能缺少安装相同的设备,您可以这样做,

npm install minizlib --save  //here `--save` will create entry into `package.json` file

After installing this package you need to restart your app. 安装此软件包后,您需要重新启动应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM