尝试运行“ npm run start”脚本时出现“ errno 1”

时间:2018-12-09 16:45:46

标签: javascript node.js npm webpack-dev-server

在我的项目文件夹中尝试运行“ npm run start”时,我不断收到此错误消息:

myLaptop:app-name userName$ npm run start

> app-name@0.1.0 start /Users/userName/My Documents/app-name
> node scripts/start.js

Cannot destructure property `compile` of 'undefined' or 'null'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app-name@0.1.0 start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the app-name@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/userName/.npm/_logs/2018-12-09T16_26_00_758Z-debug.log

基本代码是从此Medium post复制而来的,并且在我开始工作时就可以使用,但是我想我可能已经更改了某些地方,使它无法正常运行。

其他信息

  • 运行npm 6.4.1版本
  • 运行节点版本10.14.1
  • 我已经重新运行npm installnpm audit
  • 我已经重新安装了npm和node
  • 我已经删除了node-modules文件夹,然后重新运行npm install
  • 我正在使用VS-Code和git
  • 我还亲自安装了moment.js和lodash.js模块

package.json

{
    "name": "app-name",
    "version": "0.1.0",
    "private": true,
    "devDependencies": {},
    "dependencies": {
        "autoprefixer": "7.1.1",
        "babel-core": "6.25.0",
        "babel-eslint": "7.2.3",
        "babel-jest": "20.0.3",
        "babel-loader": "7.0.0",
        "babel-preset-react-app": "^3.0.1",
        "babel-runtime": "6.23.0",
        "case-sensitive-paths-webpack-plugin": "2.1.1",
        "chalk": "1.1.3",
        "css-hot-loader": "^1.3.5",
        "css-loader": "0.28.4",
        "dotenv": "4.0.0",
        "eslint": "3.19.0",
        "eslint-config-react-app": "^1.0.5",
        "eslint-loader": "1.7.1",
        "eslint-plugin-flowtype": "2.34.0",
        "eslint-plugin-import": "2.2.0",
        "eslint-plugin-jsx-a11y": "5.0.3",
        "eslint-plugin-react": "7.1.0",
        "extract-text-webpack-plugin": "2.1.2",
        "file-loader": "0.11.2",
        "fs-extra": "3.0.1",
        "gh-pages": "^1.0.0",
        "html-webpack-plugin": "2.29.0",
        "jest": "20.0.4",
        "lodash": "^4.17.11",
        "moment": "^2.22.2",
        "node-sass": "^4.5.3",
        "object-assign": "4.1.1",
        "postcss-flexbugs-fixes": "3.0.0",
        "postcss-loader": "2.0.6",
        "promise": "7.1.1",
        "react": "^15.6.1",
        "react-dev-utils": "^3.0.2",
        "react-dom": "^15.6.1",
        "react-error-overlay": "^1.0.9",
        "sass-loader": "^6.0.6",
        "style-loader": "0.18.2",
        "sw-precache-webpack-plugin": "0.11.3",
        "url-loader": "^1.1.2",
        "webpack": "2.6.1",
        "webpack-dev-server": "^3.1.10",
        "webpack-manifest-plugin": "1.1.0",
        "whatwg-fetch": "2.0.3"
    },
    "scripts": {
        "start": "node scripts/start.js",
        "predeploy": "npm run build",
        "deploy": "gh-pages -d build",
        "build": "node scripts/build.js",
        "test": "node scripts/test.js --env=jsdom"
    },
    "jest": {
        "collectCoverageFrom": [
            "src/**/*.{js,jsx}"
        ],
        "setupFiles": [
            "<rootDir>/config/polyfills.js"
        ],
        "testMatch": [
            "<rootDir>/src/**/__tests__/**/*.js?(x)",
            "<rootDir>/src/**/?(*.)(spec|test).js?(x)"
        ],
        "testEnvironment": "node",
        "testURL": "http://localhost",
        "transform": {
            "^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
            "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
            "^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
        },
        "transformIgnorePatterns": [
            "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
        ],
        "moduleNameMapper": {
            "^react-native$": "react-native-web"
        },
        "moduleFileExtensions": [
            "web.js",
            "js",
            "json",
            "web.jsx",
            "jsx",
            "scss"
        ]
    },
    "babel": {
        "presets": [
            "react-app"
        ]
    },
    "eslintConfig": {
        "extends": "react-app"
    }
}

1 个答案:

答案 0 :(得分:0)

请将webpack-dev-server的版本降级为3.0.0。

由于对等方的依赖性,webpack-dev-server 3.x仅与webpack 4.x兼容。

尝试使用最新的webpack版本,因为您使用的是2.x.x的webpack版本,因此最新版本是4.27.1

我希望这能解决问题。