使用electron-vite初始化构建electron程序以后,想通过npm install来安装想用的包但发现什么包都装不进去报一样的错,报错具体如下,好像是路径有问题。希望有大佬能看看是需要怎么改也提前感谢能回复的大佬了。。。
npm error code 1
npm error path D:\paratice\elec-image
npm error command failed
npm error command C:\Windows\system32\cmd.exe /d /s /c electron-builder install-app-deps
npm error • electron-builder version=24.13.3
npm error • loaded configuration file=D:\paratice\elec-image\electron-builder.yml
npm error ⨯ open D:\paratice\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\node_modules\elec-image\package.json: The name of the file cannot be resolved by the system.
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).resolveDependency
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:197
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).processDependencies
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:100
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:61
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
npm error /Volumes/data/Documents/app-builder/pkg/node-modules/nodeModuleCollector.go:77
npm error ⨯ D:\paratice\elec-image\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
npm error Exit code:
npm error 1 failedTask=installAppDeps stackTrace=Error: D:\paratice\elec-image\node_modules\app-builder-bin\win\x64\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
npm error Exit code:
npm error 1
npm error at ChildProcess.<anonymous> (D:\paratice\elec-image\node_modules\builder-util\src\util.ts:252:14)
npm error at Object.onceWrapper (node:events:633:26)
npm error at ChildProcess.emit (node:events:518:28)
npm error at ChildProcess.cp.emit (D:\paratice\elec-image\node_modules\cross-spawn\lib\enoent.js:34:29)
npm error at maybeClose (node:internal/child_process:1104:16)
npm error at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm error A complete log of this run can be found in: C:\Users\takuu\AppData\Local\npm-cache\_logs\2024-12-04T01_32_55_856Z-debug-0.log
刚开始是想安装quasar,发现装不上以为可能是包的问题,又装了axios试一下也一样报错。然后又根据chatgpt说的进行了下列操作
# 删除 node_modules
rm -rf node_modules
# 删除 package-lock.json 或 yarn.lock
rm package-lock.json
# 或
rm yarn.lock
# 清理 npm 缓存
npm cache clean --force
还是不行,啥的装不上,对于这个npm安装的原理是不太懂
追加补充根目录下的package.json的内容,npm i的操作也是在根目录下进行的
{
"name": "elec-image",
"version": "1.0.0",
"description": "An Electron application with Vue",
"main": "./out/main/index.js",
"author": "example.com",
"homepage": "https://electron-vite.org",
"scripts": {
"format": "prettier --write .",
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
"start": "electron-vite preview",
"dev": "electron-vite dev",
"build": "electron-vite build",
"postinstall": "electron-builder install-app-deps",
"build:unpack": "npm run build && electron-builder --dir",
"build:win": "npm run build && electron-builder --win",
"build:mac": "npm run build && electron-builder --mac",
"build:linux": "npm run build && electron-builder --linux"
},
"dependencies": {
"@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0",
"elec-image": "file:",
"quasar": "^2.17.4"
},
"devDependencies": {
"@electron-toolkit/eslint-config": "^1.0.2",
"@rushstack/eslint-patch": "^1.10.3",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-prettier": "^9.0.0",
"electron": "^31.0.2",
"electron-builder": "^24.13.3",
"electron-vite": "^2.3.0",
"eslint": "^8.57.0",
"eslint-plugin-vue": "^9.26.0",
"prettier": "^3.3.2",
"vite": "^5.3.1",
"vue": "^3.4.30"
}
}
使用管理员权限 ,打开CMD 。
在运行npm install。 可以解决。