我从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
这是调试日志文件:
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 ]
我尝试安装和重新安装minizlib,npm和node,以及在此处类似问题中发现的少数可能解决方案,但没有成功。任何帮助将不胜感激。
操作系统:Ubuntu 18.04.2
编辑: 我不太确定发生了什么,但是它确实可以正常工作。我今天打开了该项目,以查看是否有任何更改并收到有关该漏洞的一些警告。为了解决这些问题,我重新安装了expo-cli,现在似乎一切正常。
答案 0 :(得分:0)
npm install -g npm@latest
(更新npm)。
rm -rf node_modules
(以删除现有模块)。
npm install
(重新安装项目依赖项)。
答案 1 :(得分:0)
您的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
文件没有minizlib
软件包的条目。另外,node_modules
文件夹没有minizlib
文件夹。
可能缺少安装相同的软件的方法,
npm install minizlib --save //here `--save` will create entry into `package.json` file
安装此软件包后,您需要重新启动应用程序。