我经常收到这个错误,如果我删除了项目然后再次下载它然后它就可以工作了,但是在重新启动我的电脑后又出现了同样的错误。
我的全局 angular 版本和项目 angular 版本是一样的。
如果我删除节点模块并重新安装软件包它可以工作,但每次这样做都是浪费时间。
对应的错误日志:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm@6.14.11
3 info using node@v14.16.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle e-commerce-admin@0.0.0~prestart: e-commerce-admin@0.0.0
6 info lifecycle e-commerce-admin@0.0.0~start: e-commerce-admin@0.0.0
7 verbose lifecycle e-commerce-admin@0.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle e-commerce-admin@0.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\e-commerce-admin\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Users\inval\AppData\Local\Microsoft\WindowsApps;C:\Users\inval\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\inval\AppData\Roaming\npm
9 verbose lifecycle e-commerce-admin@0.0.0~start: CWD: D:\e-commerce-admin
10 silly lifecycle e-commerce-admin@0.0.0~start: Args: [ '/d /s /c', 'ng serve' ]
11 info lifecycle e-commerce-admin@0.0.0~start: Failed to exec start script
12 verbose stack Error: e-commerce-admin@0.0.0 start: `ng serve`
12 verbose stack spawn ENOENT
12 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:48:18)
12 verbose stack at ChildProcess.emit (events.js:315:20)
12 verbose stack at maybeClose (internal/child_process.js:1048:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
13 verbose pkgid e-commerce-admin@0.0.0
14 verbose cwd D:\e-commerce-admin
15 verbose Windows_NT 10.0.19042
16 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
17 verbose node v14.16.0
18 verbose npm v6.14.11
19 error code ELIFECYCLE
20 error syscall spawn
21 error file C:\Windows\system32\cmd.exe
22 error errno ENOENT
23 error e-commerce-admin@0.0.0 start: `ng serve`
23 error spawn ENOENT
24 error Failed at the e-commerce-admin@0.0.0 start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
我的 package.json
{
"name": "e-commerce-admin",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:prod": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^11.1.0",
"@angular/cdk": "^11.1.0",
"@angular/common": "^11.1.0",
"@angular/compiler": "~11.1.0",
"@angular/core": "^11.1.0",
"@angular/flex-layout": "^11.0.0-beta.33",
"@angular/forms": "^11.1.0",
"@angular/material": "^11.1.0",
"@angular/platform-browser": "~11.1.0",
"@angular/platform-browser-dynamic": "~11.1.0",
"@angular/router": "~11.1.0",
"@ng-select/ng-select": "^5.1.0",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",
"hammerjs": "^2.0.8",
"rxjs": "~6.6.3",
"tslib": "^2.1.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1101.4",
"@angular/cli": "~11.1.0",
"@angular/compiler-cli": "~11.1.0",
"@angular/language-service": "~11.1.0",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^14.14.22",
"codelyzer": "^6.0.1",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.2.3",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~7.0.0",
"tslint": "~6.1.0",
"typescript": "~4.0.5"
}
}
答案 0 :(得分:0)
似乎有些软件包没有安装。您需要安装软件包,然后尝试运行该应用。
尝试以下步骤。
npm cache clean --force
npm cache verify
npm install
npm start
或ng serve
让我知道这是否有效。
答案 1 :(得分:0)
发生这种情况可能是因为您使用的是 node 的更新版本。尝试将您的节点版本降级到 12.11.x or later minor version
。
参考:https://gist.github.com/LayZeeDK/c822cc812f75bb07b7c55d07ba2719b3
答案 2 :(得分:0)
这可能不是 node、npm 或 angular 的问题,