在reactjs中安装节点模块时出错

时间:2019-09-27 09:03:21

标签: node.js reactjs npm

收到以下显示的错误,我试图为我的react js项目使用npm i命令安装节点模块

D:\Rev>npm i

> node-sass@4.12.0 install D:\Rev\node_modules\node-sass
> node scripts/install.js

Cached binary found at C:\Users\admin\AppData\Roaming\npm-cache\node-sass\4.12.0\win32-x64-64_binding.node

> node-sass@4.12.0 postinstall D:\Rev\node_modules\node-sass
> node scripts/build.js

Binary found at D:\Rev\node_modules\node-sass\vendor\win32-x64-64\binding.node
Testing binary
Binary is fine

> react-vertical-timeline-component@2.5.0 postinstall D:\Rev\node_modules\react-vertical-timeline-component
> node lib/post_install.js


> example-project@1.0.0 postinstall D:\Rev
> set NODE_ENV=production && npm run build-prod


> example-project@1.0.0 build-prod D:\Rev
> webpack --mode production --config webpack/webpack.production.config.js --progress --colors

D:\Rev\node_modules\webpack-cli\bin\config-yargs.js:89
                                describe: optionsSchema.definitions.output.properties.path.description,
                                                                           ^

TypeError: Cannot read property 'properties' of undefined
    at module.exports (D:\Rev\node_modules\webpack-cli\bin\config-yargs.js:89:48)
    at D:\Rev\node_modules\webpack-cli\bin\webpack.js:60:27
    at Object.<anonymous> (D:\Rev\node_modules\webpack-cli\bin\webpack.js:515:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! example-project@1.0.0 build-prod: `webpack --mode production --config webpack/webpack.production.config.js --progress --colors`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the example-project@1.0.0 build-prod 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!     C:\Users\admin\AppData\Roaming\npm-cache\_logs\2019-09-27T08_52_21_812Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! example-project@1.0.0 postinstall: `set NODE_ENV=production && npm run build-prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the example-project@1.0.0 postinstall 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!     C:\Users\admin\AppData\Roaming\npm-cache\_logs\2019-09-27T08_52_21_942Z-debug.log

package.json如下:

{
  "name": "example-project",
  "version": "1.0.0",
  "description": "",
  "main": "bundle.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev-server": "set NODE_ENV=development && webpack-dev-server --mode development --config webpack/webpack.config.js --progress --colors",
    "build": "set NODE_ENV=development && webpack --config webpack/webpack.production.config.js --progress --colors",
    "build-prod": "webpack --mode production --config webpack/webpack.production.config.js --progress --colors",
    "postinstall": "set NODE_ENV=production && npm run build-prod"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-eslint": "^8.2.3",
    "babel-loader": "^7.1.4",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "css-loader": "^0.28.11",
    "eslint": "^4.19.1",
    "eslint-loader": "^2.0.0",
    "eslint-plugin-react": "^7.8.2",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "node-sass": "^4.9.0",
    "react-collapsible": "^2.2.0",
    "sass-loader": "^7.0.1",
    "style-loader": "^0.21.0",
    "webpack": "^4.8.3",
    "webpack-cli": "^2.1.5",
    "webpack-dev-server": "^3.1.4",
    "webpack-merge": "^4.1.2"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-react": "^6.24.1",
    "classnames": "^2.2.5",
    "dnd-core": "^3.0.2",
    "file-loader": "^1.1.11",
    "file-system": "^2.2.2",
    "foundation-sites": "^6.4.3",
    "gatsby-plugin-glamor": "^1.6.13",
    "glamor": "^2.20.40",
    "history": "^4.7.2",
    "jquery": "^3.3.1",
    "lodash": "^4.17.10",
    "moment": "^2.22.1",
    "qs": "^6.5.2",
    "raf": "^3.4.1",
    "rc-tree": "^1.11.4",
    "react": "^16.3.2",
    "react-autocomplete": "^1.8.1",
    "react-column-resizer": "^1.1.8",
    "react-datepicker": "^1.5.0",
    "react-dialog": "^1.0.2",
    "react-dnd": "^3.0.2",
    "react-dnd-html5-backend": "^2.6.0",
    "react-dom": "^16.3.2",
    "react-dropzone": "^4.2.9",
    "react-html-table-to-excel": "^2.0.0",
    "react-idle-timer": "^3.0.0",
    "react-js-pagination": "^3.0.2",
    "react-redux": "^5.0.7",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "react-router-redux": "^5.0.0-alpha.9",
    "react-simple-dropdown": "^3.2.0",
    "react-sortable-hoc": "^0.8.4",
    "react-toastify": "^4.0.1",
    "react-tooltip": "^3.10.0",
    "react-transition-group": "^2.3.1",
    "react-vertical-timeline-component": "^2.0.6",
    "react-widgets": "^4.2.6",
    "redux": "^3.7.2",
    "redux-form": "^7.3.0",
    "redux-thunk": "^2.2.0",
    "uglifyjs-webpack-plugin": "^1.2.5",
    "universal-cookie": "^2.1.2",
    "url-loader": "^1.0.1"
  }
}

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

您能否尝试完全删除本地node_modules

然后打电话

 npm cache verify

npm cache clean

https://docs.npmjs.com/cli/cache.html

然后尝试再次npm i