我有2个模块。
here local.properties 放置您的android sdk路径
运行 npm start
时出现以下错误Looking for JS files in
/home/company/Desktop/projects/someapp/vendorapp
Loading dependency graph...(node:9505) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
Duplicate module name: react-animated
Paths: /home/company/Desktop/projects/someapp/vendorapp/node_modules/storybook/node_modules/react-native/Libraries/Animated/release/package.json collides with /home/company/Desktop/projects/someapp/vendorapp/node_modules/react-native/Libraries/Animated/release/package.json
This error is caused by `hasteImpl` returning the same name for different files.
at setModule (/home/company/Desktop/projects/someapp/vendorapp/node_modules/metro/node_modules/jest-haste-map/build/index.js:569:17)
at workerReply (/home/company/Desktop/projects/someapp/vendorapp/node_modules/metro/node_modules/jest-haste-map/build/index.js:641:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:9505) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:9505) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:9505) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
Duplicate module name: react-animated
Paths: /home/company/Desktop/projects/someapp/vendorapp/node_modules/storybook/node_modules/react-native/Libraries/Animated/release/package.json collides with /home/company/Desktop/projects/someapp/vendorapp/node_modules/react-native/Libraries/Animated/release/package.json
This error is caused by `hasteImpl` returning the same name for different files.
at setModule (/home/company/Desktop/projects/someapp/vendorapp/node_modules/metro/node_modules/jest-haste-map/build/index.js:569:17)
at workerReply (/home/company/Desktop/projects/someapp/vendorapp/node_modules/metro/node_modules/jest-haste-map/build/index.js:641:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:9505) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
无法找出许多其他尝试过的stackoverflow链接,但没有一个解决。以下是 package.json 文件
的详细信息让我知道是否需要其他详细信息。
本机故事书 Package.json
{
"name": "storybook",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"storybook": "storybook start"
},
"dependencies": {
"native-base": "^2.8.2",
"react": "16.6.3",
"react-native": "0.58.3",
"react-native-material-textfield": "^0.12.0",
"toggle-switch-react-native": "^2.0.2"
},
"devDependencies": {
"@storybook/addon-actions": "^4.1.2",
"@storybook/addon-links": "^4.1.2",
"@storybook/addons": "^4.1.2",
"@storybook/react-native": "^4.1.2",
"babel-core": "^6.26.3",
"babel-jest": "23.6.0",
"babel-plugin-module-resolver": "^3.1.1",
"babel-runtime": "^6.26.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.49.2",
"prop-types": "^15.6.2",
"react-dom": "16.6.3",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
反应本地应用
{
"name": "vendorapp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.6.3",
"react-native": "0.58.3",
"react-redux": "^6.0.0",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"storybook": "../storybook"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "24.0.0",
"jest": "24.0.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}