gpt4 book ai didi

reactjs - 用 React 测试

转载 作者:行者123 更新时间:2023-11-28 21:25:44 25 4
gpt4 key购买 nike

我似乎无法再测试我的文件了。

我“npm i react react-dom react-addon-test-utils”

但即使在所有这些安装之后,

它告诉我我错过了什么

我什至尝试安装两个 devdep。和部门。

module.js:339
throw err;
^

Error: Cannot find module 'react-dom/lib/ReactTestUtils'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/react-addons-test-utils/index.js:1:80)
at Module._compile (module.js:425:26)
at Module._extensions..js (module.js:432:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at /Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/enzyme/build/react-compat.js:92:17
at Object.<anonymous> (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/enzyme/build/react-compat.js:146:5)
at Module._compile (module.js:425:26)
at Module._extensions..js (module.js:432:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/enzyme/build/Utils.js:29:20)
at Module._compile (module.js:425:26)
at Module._extensions..js (module.js:432:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/enzyme/build/MountedTraversal.js:32:14)
at Module._compile (module.js:425:26)
at Module._extensions..js (module.js:432:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/enzyme/build/ReactWrapper.js:23:25)
at Module._compile (module.js:425:26)
at Module._extensions..js (module.js:432:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/enzyme/build/index.js:15:21)
at Module._compile (module.js:425:26)
at Module._extensions..js (module.js:432:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (AddNewSong.spec.js:5:28)
at Module._compile (module.js:425:26)
at loader (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/babel-register/lib/node.js:128:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/babel-register/lib/node.js:138:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at /Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/mocha/lib/mocha.js:219:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/mocha/lib/mocha.js:216:14)
at Mocha.run (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/mocha/lib/mocha.js:468:10)
at Object.<anonymous> (/Users/Kainoa/DevLeague/kanakaHacks_Software/KanakaMusicR/kanakamusicR_A/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:136:18)
at node.js:972:3
npm ERR! Test failed. See above for more details.

这是 package.json

{
"name": "KMR",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"start": "node app.js",
"build": "webpack",
"watch": "webpack --watch",
"test": "mocha --require test/helpers/setup.js",
"lint": "eslint --ignore-path .gitignore --cache ./",
"cover": "nyc --reporter=lcov --reporter=text --reporter=html --require babel-register --extension .jsx npm test"
},
"license": "MIT",
"dependencies": {
"axios": "0.9.1",
"bluebird": "^3.4.6",
"errorhandler": "^1.4.3",
"express": "4.13.4",
"express-favicon": "^2.0.0",
"express-jwt": "^5.1.0",
"lodash": "4.6.1",
"method-override": "^2.3.6",
"mysql": "^2.11.1",
"node-ensure": "0.0.0",
"pg": "^6.1.0",
"pg-hstore": "^2.3.2",
"pg-promise": "^5.3.4",
"react": "0.14.7",
"react-dom": "0.14.7",
"react-modal": "^1.5.2",
"react-redux": "4.4.0",
"react-responsive": "^1.2.5",
"react-router": "2.0.0",
"redux": "3.3.1",
"sequelize": "^2.1.3",
"sequelize-cli": "^2.4.0",
"sqlite3": "^3.1.6",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.8.4",
"webpack-hot-middleware": "^2.13.0"
},
"devDependencies": {
"babel-core": "6.5.2",
"babel-loader": "6.2.2",
"babel-polyfill": "6.7.4",
"babel-preset-es2015": "6.5.0",
"babel-preset-react": "6.5.0",
"babel-register": "6.5.2",
"chai": "3.5.0",
"enzyme": "2.0.0",
"eslint": "2.2.0",
"eslint-config-standard": "5.1.0",
"eslint-config-standard-jsx": "1.1.1",
"eslint-config-standard-react": "2.3.0",
"eslint-loader": "1.3.0",
"eslint-plugin-promise": "1.0.8",
"eslint-plugin-react": "4.1.0",
"eslint-plugin-standard": "1.3.2",
"gulp": "^3.9.1",
"gulp-connect": "^5.0.0",
"gulp-sass": "^2.3.2",
"jsdom": "8.0.4",
"json-loader": "0.5.4",
"livereload": "^0.6.0",
"mocha": "2.4.5",
"nyc": "6.0.0",
"react": "^0.14.7",
"react-addons-test-utils": "^15.4.1",
"react-dom": "^0.14.7",
"sinon": "^1.17.3",
"supertest": "^2.0.1",
"webpack": "1.13.2"
},
"directories": {
"test": "test"
},
"keywords": [
"react",
"workshop",
"intro",
"redux"
]
}

最佳答案

我从 here 找到了解决此问题的方法

make sure that your app contains follow dependencies all in the sameversion in package.json

react-addons-test-utils

react

react-dom

"react": "^0.14.7",
"react-addons-test-utils": "^0.14.7",
"react-dom": "^0.14.7",

或者升级到上述依赖的最新版本

关于reactjs - 用 React 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40987910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com