Eni*_*ili 4 android reactjs react-native
react-native:0.57.0纱线:1.9.4 nodejs:9.10.1
react-native run-android给我这个错误:
[android, dev] ..\..\../index.js ???????????????? 0.0% (0/1)::ffff:127.0.0.1 - - [14/Sep/2018:07:12:00 +0000] "GET /index.delta?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.10.0"
error: bundling failed: ReferenceError: SHA-1 for file c:\wamp64\www\React\hello1\index.js is not computed
at DependencyGraph.getSha1 (c:\wamp64\www\React\hello1\node_modules\metro\src\node-haste\DependencyGraph.js:238:119)
at c:\wamp64\www\React\hello1\node_modules\metro\src\Bundler.js:168:56
at Generator.next (<anonymous>)
at step (c:\wamp64\www\React\hello1\node_modules\metro\src\Bundler.js:11:657)
at c:\wamp64\www\React\hello1\node_modules\metro\src\Bundler.js:11:817
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
Run Code Online (Sandbox Code Playgroud)
看起来像是有关地铁的问题。
尝试关闭控制台并在项目文件夹中运行:
rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && rm -rf node_modules/ && npm install && npm start -- --reset-cache
Run Code Online (Sandbox Code Playgroud)
然后跑
react-native run-android
对于Windows,清理缓存应如下所示:
del %appdata%\Temp\react-* & del %appdata%\Temp\metro-* & del %appdata%\Temp\haste-* & del node_modules & npm install & watchman watch-del-all & npm start -- --reset-cache
(我没有在Windows上尝试过,可能是Windows删除node_modules的最佳选择是安装rimraf
)
如果仍然无法正常工作,请检查package.json和.babelrc。您应该具有以下内容:
"metro-react-native-babel-preset": "^0.45.0"
和.babelrc配置:
{
"presets": ["module:metro-react-native-babel-preset"]
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4391 次 |
最近记录: |