簡體   English   中英

NPM 版本太舊

[英]Version too old of the NPM

我正在處理一個問題。 我的 Laravel 項目是一個舊項目,我無法運行npm run dev 讓我們看一些代碼:

php artisan laravel --version: Laravel Framework 5.8.38

node --version: v16.16.0這是實際安裝的Node版本

以及運行NPM時的錯誤:

MacBook-Pro-de-Marcello:webroker marcellopato$ npm run dev
npm WARN npm npm does not support Node.js v16.16.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
npm WARN npm You can find the latest version at https://nodejs.org/

> @ dev /Users/marcellopato/Documents/Sites/webroker
> npm run development

npm WARN npm npm does not support Node.js v16.16.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
npm WARN npm You can find the latest version at https://nodejs.org/

> @ development /Users/marcellopato/Documents/Sites/webroker
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn node_modules/webpack/bin/webpack.js ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn node_modules/webpack/bin/webpack.js',
  path: 'node_modules/webpack/bin/webpack.js',
  spawnargs: [
    '--progress',
    '--hide-modules',
    '--config=node_modules/laravel-mix/setup/webpack.config.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/marcellopato/.npm/_logs/2022-08-29T14_40_33_577Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/marcellopato/.npm/_logs/2022-08-29T14_40_33_659Z-debug.log

package.json:

    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.18.0",
        "bootstrap": "^4.1.3",
        "cross-env": "^5.2.0",
        "jquery": "^3.2",
        "laravel-mix": "^2.1.14",
        "lodash": "^4.17.11",
        "popper.js": "^1.14.3",
        "vue": "^2.5.16",
        "vuedraggable": "^2.16.0"
    },
    "dependencies": {
        "@tinymce/tinymce-vue": "^1.1.0",
        "@websanova/vue-upload": "^0.2.14-beta",
        "ajv": "^6.5.4",
        "jquery-filepond": "^1.0.0",
        "laravel-echo": "^1.4.0",
        "moment": "^2.22.2",
        "moment-timezone": "^0.5.21",
        "node-sass": "^4.9.4",
        "npm": "^6.4.1",
        "pusher-js": "^4.3.1",
        "tinymce-vue-2": "0.0.5",
        "v-calendar": "^0.9.7",
        "vlightbox": "^2.0.2",
        "vue-chat-scroll": "^1.2.0",
        "vue-google-charts": "^0.3.2",
        "vue-moment": "^4.0.0",
        "vue-scrollto": "^2.13.0",
        "vue-simple-lightbox": "^1.1.0",
        "vue-template-compiler": "^2.5.17",
        "vue-the-mask": "^0.11.1",
        "vue-toasted": "^1.1.25",
        "vue-upload-component": "^2.8.14",
        "vue-wysiwyg": "^1.7.2",
        "vue2-daterange-picker": "^0.1.1",
        "vue2-dropzone": "^3.5.2",
        "vue2-editor": "^2.6.1"
    }
}

我認為這個問題與 Node 的實際版本有關,它太新了。 可能是這樣嗎? 如果是這樣,有一種方法可以知道我第一次從事該項目時在我的機器上安裝了什么版本?

還是這個問題是一個新問題?

可能你現在的npm和node版本不兼容。

我建議你重新安裝 npm 然后重新安裝節點。

  1. 刪除 npm Mac: sudo npm 卸載 -g npm

    Windows:npm卸載-g npm

  2. 安裝 node.js https://nodejs.org

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM