npm install JSON.parse Unexpected token "}" (0x7D) in JSON at position 98 while parsing near "...: \"vite build\",\n },\n \"devDependenc..."

Ray*_*ras 1 npm laravel npm-install

你好,我正在npm install我的 laravel 项目中安装,但出现错误

npm ERR! code EJSONPARSE
npm ERR! path C:\xampp\htdocs\laravel_project/package.json
npm ERR! JSON.parse Unexpected token "}" (0x7D) in JSON at position 98 while parsing near "...: \"vite 
build\",\n    },\n    \"devDependenc..."
npm ERR! JSON.parse Failed to parse JSON data.
npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\my_PC\AppData\Local\npm-cache\_logs\2022-11-16T13_59_50_980Z-debug-0.log
PS C:\xampp\htdocs\laravel_project> 
Run Code Online (Sandbox Code Playgroud)

我已经尝试删除我的node_modulepackage-lock.json中的内容并且已经做了这些

npm cache clear --force
npm cache verify
Run Code Online (Sandbox Code Playgroud)

他们都给了我同样的错误

我使用的作曲家版本

Composer version 2.4.4 2022-10-27 14:39:29
Run Code Online (Sandbox Code Playgroud)

我的 npm 版本

npm version 9.1.1
Run Code Online (Sandbox Code Playgroud)

我的包.json

{
    "private": true,
    "scripts": {
        "dev": "vite",
        "build": "vite build",
    },
    "devDependencies": {
        "@popperjs/core": "^2.10.2",
        "@vitejs/plugin-vue": "^3.0.1",
        "axios": "^1.1.2",
        "bootstrap": "^5.2.1",
        "laravel-vite-plugin": "^0.6.0",
        "lodash": "^4.17.19",
        "postcss": "^8.1.14",
        "sass": "^1.32.11",
        "vite": "^3.0.0",
        "vue": "^3.2.37"
    }
}
Run Code Online (Sandbox Code Playgroud)

Had*_*adi 8

只需删除后面的逗号(,)vite build即可解决问题。

{
    "private": true,
    "scripts": {
        "dev": "vite",
        "build": "vite build"
    },
    "devDependencies": {
        "@popperjs/core": "^2.10.2",
        "@vitejs/plugin-vue": "^3.0.1",
        "axios": "^1.1.2",
        "bootstrap": "^5.2.1",
        "laravel-vite-plugin": "^0.6.0",
        "lodash": "^4.17.19",
        "postcss": "^8.1.14",
        "sass": "^1.32.11",
        "vite": "^3.0.0",
        "vue": "^3.2.37"
    }
}
Run Code Online (Sandbox Code Playgroud)