问题:
我的项目有一个@providesModule naming collision
尝试从命令行运行react-native run-ios
.它与自动生成的dir冲突,dist/
后者是由另一个npm包esdoc创建的.我希望能够保留这个自动生成的目录,并让反应原生包装器忽略该dist/
目录.
错误信息:
[01/23/2017, 13:17:07]Building Haste Map Failed to build DependencyGraph: @providesModule naming collision: Duplicate module name: ann Paths: /Users/thurt/projects/example/package.json collides with /Users/thurt/projects/example/dist/esdoc/package.json This error is caused by a @providesModule declaration with the same name across two different files. Error: @providesModule naming collision: Duplicate module name: ann Paths: /Users/thurt/projects/example/package.json collides with /Users/thurt/projects/example/dist/esdoc/package.json This error is caused by a @providesModule declaration with the same name across two different files. at HasteMap._updateHasteMap (/Users/thurt/projects/example/node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:158:13) at p.getName.then.name (/Users/thurt/projects/example/node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:133:31)
Rob Hogan.. 32
你几乎在https://github.com/facebook/react-native/issues/12131
您可以在项目根目录中创建一个metro.config.js
使用(特定于版本)内容调用的文件,如下所示:
对于反应原生> = 0.57
const blacklist = require('metro-config/src/defaults/blacklist'); // blacklist is a function that takes an array of regexes and combines // them with the default blacklist to return a single regex. module.exports = { resolver: { blacklistRE: blacklist([/dist\/.*/]) } };
对于反应原生> = 0.52,<0.57
const blacklist = require('metro-config/src/defaults/blacklist'); // blacklist is a function that takes an array of regexes and combines // them with the default blacklist to return a single regex. module.exports = { resolver: { blacklistRE: blacklist([/dist\/.*/]) } };
对于React Native> = 0.46,<0.52.
const blacklist = require('metro').createBlacklist; module.exports = { getBlacklistRE: function() { return blacklist([/dist\/.*/]); } };
对于React Native <0.46.
const blacklist = require('metro-bundler').createBlacklist; module.exports = { getBlacklistRE: function() { return blacklist([/dist\/.*/]); } };
所有版本:
让CLI命令通过传递rn-cli.config.js
选项使用此配置:
rn-cli.config.js
(NB可能是您需要传递rn-cli.config.js
参数的错误,此位置可能应该自动加载但rn-cli.config.js
优先级)
请注意,您的--config
文件夹可能已被包装程序缓存,在这种情况下,您第一次运行它时可能需要重置缓存:
react-native run-ios --config=rn-cli.config.js
你几乎在https://github.com/facebook/react-native/issues/12131
您可以在项目根目录中创建一个metro.config.js
使用(特定于版本)内容调用的文件,如下所示:
对于反应原生> = 0.57
const blacklist = require('metro-config/src/defaults/blacklist'); // blacklist is a function that takes an array of regexes and combines // them with the default blacklist to return a single regex. module.exports = { resolver: { blacklistRE: blacklist([/dist\/.*/]) } };
对于反应原生> = 0.52,<0.57
const blacklist = require('metro-config/src/defaults/blacklist'); // blacklist is a function that takes an array of regexes and combines // them with the default blacklist to return a single regex. module.exports = { resolver: { blacklistRE: blacklist([/dist\/.*/]) } };
对于React Native> = 0.46,<0.52.
const blacklist = require('metro').createBlacklist; module.exports = { getBlacklistRE: function() { return blacklist([/dist\/.*/]); } };
对于React Native <0.46.
const blacklist = require('metro-bundler').createBlacklist; module.exports = { getBlacklistRE: function() { return blacklist([/dist\/.*/]); } };
所有版本:
让CLI命令通过传递rn-cli.config.js
选项使用此配置:
rn-cli.config.js
(NB可能是您需要传递rn-cli.config.js
参数的错误,此位置可能应该自动加载但rn-cli.config.js
优先级)
请注意,您的--config
文件夹可能已被包装程序缓存,在这种情况下,您第一次运行它时可能需要重置缓存:
react-native run-ios --config=rn-cli.config.js