npm install 在这么多警告后给出错误
Posted
技术标签:
【中文标题】npm install 在这么多警告后给出错误【英文标题】:npm install giving Error after so many WARN 【发布时间】:2020-10-26 11:26:53 【问题描述】:我的 ReactJS 项目直到上周都运行良好,但从周日开始,它在 npm install 上出现以下错误:
PS C:\Projects\Interface\ClientApp> npm install
npm WARN deprecated material-ui-icons@1.0.0-beta.36: Use @material-ui/icons instead
npm WARN deprecated material-ui@0.20.2: You can now upgrade to @material-ui/core
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not
recommended for usage due to the number of issues. Please, upgrade your
dependencies to the actual version of core-js@3.
npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core,
this package is dedicated to the legacy v1
npm WARN deprecated material-ui-pickers@2.2.4: You can now upgrade to
@material-ui/pickers. Documentation for v2 can be found at
https://material-ui-pickers-v2.dmtr-kovalenko.now.sh/
npm WARN deprecated extract-text-webpack-plugin@3.0.2: Deprecated. Please use
https://github.com/webpack-contrib/mini-css-extract-plugin
npm WARN deprecated fsevents@1.1.2: fsevents 1 will break on node v14+ and could
be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated core-js@1.2.7: core-js@<3 is no longer maintained and not
recommended for usage due to the number of issues. Please, upgrade your
dependencies to the actual version of core-js@3.
npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()
npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading
Browserslist >3.0 config used in other tools.
npm WARN deprecated sw-precache@5.2.1: Please migrate to Workbox:
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
npm WARN deprecated chokidar@1.7.0: Chokidar 2 will break on node v14+.
Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated sw-toolbox@3.6.0: Please migrate to Workbox:
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could
be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated hawk@3.1.3: This module moved to @hapi/hawk. Please make sure to
switch over as this distribution is no longer supported and may contain
bugs and critical security issues.
npm WARN deprecated request@2.81.0: request has been deprecated,
see https://github.com/request/request/issues/3142
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade
to chokidar 3 with 15x less dependencies.
npm WARN deprecated request@2.88.2: request has been deprecated, see
https://github.com/request/request/issues/3142
npm WARN deprecated os-homedir@2.0.0: This is not needed anymore.
Use `require('os').homedir()` instead.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading
Browserslist >3.0 config used in other tools.
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only,
flatted is its successor. npm WARN deprecated hoek@2.16.3: This version
has been deprecated in accordance with the hapi support policy (hapi.im/support).
Please upgrade to the latest version to get the best features, bug fixes,
and security patches. If you are unable to upgrade at this time, paid
support is available for older versions (hapi.im/commercial).
npm WARN deprecated cryptiles@2.0.5: This version has been deprecated in accordance
with the hapi support policy (hapi.im/support). Please upgrade to the
latest version to get the best features, bug fixes, and security patches.
If you are unable to upgrade at this time, paid support is available for
older versions (hapi.im/commercial).
npm WARN deprecated boom@2.10.1: This version has been deprecated in accordance
with the hapi support policy (hapi.im/support). Please upgrade to the
latest version to get the best features, bug fixes, and security patches.
If you are unable to upgrade at this time, paid support is available for
older versions (hapi.im/commercial).
npm WARN deprecated sntp@1.0.9: This module moved to @hapi/sntp. Please make sure
to switch over as this distribution is no longer supported and may contain
bugs and critical security issues.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm ERR! Unexpected end of JSON input while parsing near '...on" : "10.16.3"
npm ERR! '
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\AppData\Roaming\npm-cache\_logs\2020-07-06T10_18_35_852Z-debug.log
注意
-
我已将 npm 从 6.9.0 升级到 6.14.5,然后也面临同样的问题
我删除了 package.json.lock 和 node_modules 然后也面临同样的问题
请让我知道我还缺少什么? --------------我的package.json--------------
"name": "clientapp",
"version": "0.1.0",
"private": true,
"dependencies":
"@material-ui/core": "^4.9.5",
"@material-ui/icons": "^4.4.1",
"@material-ui/lab": "^4.0.0-alpha.45",
"@material/typography": "^3.1.0",
"@trendmicro/react-sidenav": "^0.4.5",
"axios": "^0.19.0",
"bootstrap": "^3.4.1",
"flux": "^3.1.3",
"jquery": "^3.4.1",
"match-sorter": "^4.0.2",
"material-grid": "^0.1.0",
"material-table": "^1.54.2",
"material-ui": "^0.20.2",
"material-ui-colors": "^1.0.0",
"material-ui-icons": "^1.0.0-beta.36",
"mdbreact": "^4.22.0",
"oidc-client": "^1.5.4",
"plotly.js": "^1.49.4",
"prop-types": "^15.7.2",
"react": "^16.13.0",
"react-bootstrap": "^0.31.5",
"react-bootstrap-tabs": "^1.0.2",
"react-dom": "^16.13.0",
"react-flippy": "^0.1.5",
"react-loader-spinner": "^3.1.5",
"react-minimal-pie-chart": "^6.0.1",
"react-plotly.js": "^2.3.0",
"react-redux": "^7.1.3",
"react-redux-loading-bar": "^4.5.0",
"react-router-bootstrap": "^0.24.4",
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.17",
"react-slideshow-image": "^1.4.0",
"react-sortable-tree": "^2.7.1",
"react-stack-grid": "^0.7.1",
"react-stonecutter": "^0.3.10",
"react-table": "^7.0.0-rc.15",
"react-web-tabs": "^1.0.1",
"redux": "^4.0.4",
"rimraf": "^2.6.2",
"webpack": "*"
,
"scripts":
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
【问题讨论】:
你必须使用material-ui最新版本 @JayParmar :它将通过命令行升级命令完成,或者我将为我使用的每个包单独执行此操作? 【参考方案1】:尝试升级到@material-ui/core
。
material-ui
包已弃用。
【讨论】:
所以我应该简单地从我的 package.json 中删除 "@material-ui/core": "^4.9.5",然后再次从 cmd 中删除 - "npm install @material-ui/core" ?【参考方案2】:如果您看到日志,对于旧包,它会给出警告而不是错误。错误其实是这一行:npm ERR! Unexpected end of JSON input while parsing near '...on" : "10.16.3"
npm ERR!'
由于您没有包含整个日志,因此我猜想这可能是由于引用未正确解决而导致的歧义问题!
以管理员权限打开命令提示符/powershell/终端等。执行以下操作:-
sudo npm cache clean --force
sudo npm cache verify
删除位于C:\Users\<your_username>
中的package-lock.json
文件
现在尝试使用 npm i
从您的项目文件夹安装您的项目依赖项。
注意: - 如果这不起作用,请按照与上述相同的过程(再次)并卸载 npm
和 node
并重新安装它。那么它应该可以工作了!
【讨论】:
以上是关于npm install 在这么多警告后给出错误的主要内容,如果未能解决你的问题,请参考以下文章
npm install from tfs feed(在构建过程中)给出错误:无法验证
npm install -g create-react-app 给出错误
npm run serve 给出错误 sh: vue-cli-service: command not found in Vue Cli app