运行打包程序时出现以下错误:
Error: Unable to find file with path: /Users/erem/thrivespace/react-mobile/node_modules/react-native/packager/react-packager/src/Resolver/polyfills/prelude_dev.js
at Fastfs.readFile (/Users/erem/thrivespace/react-mobile/node_modules/node-haste/lib/fastfs.js:141:15)
at /Users/erem/thrivespace/react-mobile/node_modules/node-haste/lib/Module.js:168:49
at Cache.get (/Users/erem/thrivespace/react-mobile/node_modules/node-haste/lib/Cache/index.js:64:103)
at Polyfill.read (/Users/erem/thrivespace/react-mobile/node_modules/node-haste/lib/Module.js:167:26)
at Bundler._toModuleTransport (index.js:524:14)
at toModuleTransport (index.js:400:14)
at Array.map (native)
at index.js:416:48
at tryCallOne (/Users/erem/thrivespace/react-mobile/node_modules/promise/lib/core.js:37:12)
at /Users/erem/thrivespace/react-mobile/node_modules/promise/lib/core.js:123:15
我已经跑了:
rm -rf node_modules
npm cache clean
npm install
我目前正在运行React Native 0.24.0。
答案 0 :(得分:2)
这是一个缓存问题。请参阅:https://github.com/facebook/react-native/issues/1924
您需要清除打包缓存:
rm -fr $TMPDIR/react-*
或者这似乎也可以解决问题:
watchman watch-del-all
答案 1 :(得分:1)
如果您正在使用自己的rn-cli.config.js,请尝试使用它。
我使用了一个糟糕的rn-cli.config.js文件浪费了很多时间。它工作了一段时间,直到它没有。
就我而言,我使用的是:
var blacklist = require('react-native/packager/blacklist');
var config = {
getBlacklistRE(platform) {
return blacklist(platform, [
/src/
]);
}
};
module.exports = config;
当我应该使用它时:
var blacklist = require('react-native/packager/blacklist');
var config = require('react-native/packager/rn-cli.config');
config.getBlacklistRE = function(platform) {
return blacklist(platform, [
/src/
]);
};
module.exports = config;