Webpack一直在寻找/home/user/package.json

时间:2018-12-26 12:59:48

标签: reactjs webpack jestjs babeljs babel-jest

我用create-react-app创建了一个React应用程序。我尝试运行npm run test,但webpack似乎抱怨找不到/home/sco/package.json。 package.json不应该在/home/users/klx/react/klx-sco中。我从/home/users/klx/react/klx-sco目录运行npm run test,该目录包含package.json文件,如下所示:

{
  "name": "klx-sco",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.18.0",
    "react": "^16.7.0",
    "react-dom": "^16.7.0",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "ieslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

执行测试时的完整消息如下:

 FAIL  src/App.test.js
  ● Test suite failed to run

    Cannot find module '/home/sco/package.json'

      at getBabelRC (node_modules/babel-jest/build/index.js:117:41)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.083s
Ran all test suites.

Watch Usage: Press w to show more.

我缺少什么才能正确执行测试?我该如何解决找不到package.json的问题?

0 个答案:

没有答案