NodeJS 克隆Angular项目npm失败ELIFECYCLE

u1ehiz5o  于 2023-08-04  发布在  Node.js
关注(0)|答案(2)|浏览(79)

你好,我有一个Angular项目,我想克隆。
当我用IntelliJ或VSCode启动前端时,我得到以下错误消息。

C:\Users\developer.me\Downloads\TestClone\node_modules\.bin\ng:2                     
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")                                     
          ^^^^^^^                                                                         
                                                                                          
SyntaxError: missing ) after argument list                                                
    at internalCompileFunction (node:internal/vm:73:18)                                   
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)                                
    at Module._compile (node:internal/modules/cjs/loader:1220:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.16.1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! schreibmaschine-side@0.0.0 start: `node --max_old_space_size=4096 ./node_modules/.bin/ng serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the schreibmaschine-side@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\developer.schatzl\AppData\Roaming\npm-cache\_logs\2023-08-03T08_32_31_694Z-debug.log

Process finished with exit code 1

字符串
同样让我困惑的是错误之前的以下消息
这是我的package.json

{
  "name": "schreibmaschine-side",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "node --max_old_space_size=4096 ./node_modules/.bin/ng serve",
    "build-silent": "./node_modules/.bin/tsc --noEmit",
    "build-prod": "node --max_old_space_size=4096 ./node_modules/.bin/ng build --prod --aot",
    "test": "ng test",
    "lint": "NODE_OPTIONS=\"--max-old-space-size=4096\" tslint --project . --fix",
    "e2e": "ng e2e"
  },
  "husky": {
    "hooks": {
      "pre-commit": "npm run lint && npm run build-silent"
    }
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~10.0.0-rc.3",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "~10.0.0-rc.3",
    "@angular/compiler": "~10.0.0-rc.3",
    "@angular/core": "~10.0.0-rc.3",
    "@angular/forms": "~10.0.0-rc.3",
    "@angular/material": "^9.2.4",
    "@angular/material-moment-adapter": "^9.2.4",
    "@angular/platform-browser": "~10.0.0-rc.3",
    "@angular/platform-browser-dynamic": "~10.0.0-rc.3",
    "@angular/router": "~10.0.0-rc.3",
    "angular": "^1.7.9",
    "aws-amplify": "^1.2.4",
    "aws-amplify-angular": "^4.1.1",
    "aws-sdk": "^2.585.0",
    "immutable": "^4.0.0-rc.12",
    "jwt-decode": "^2.2.0",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "rxjs": "~6.5.5",
    "stripe": "^7.15.0",
    "tslib": "^1.10.0",
    "uuid": "^3.3.3",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-builders/jest": "^8.3.1",
    "@angular-devkit/build-angular": "~0.901.7",
    "@angular/cli": "^9.1.8",
    "@angular/compiler-cli": "~10.0.0-rc.3",
    "@angular/language-service": "~10.0.0-rc.3",
    "@types/jasminewd2": "~2.0.3",
    "@types/jest": "^24.9.1",
    "@types/lodash": "^4.14.148",
    "@types/moment": "^2.13.0",
    "@types/node": "^12.11.1",
    "@types/stripe-v3": "^3.1.13",
    "codelyzer": "^5.1.2",
    "file-saver": "^2.0.2",
    "husky": "^4.2.5",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "jest": "^24.9.0",
    "jest-extended": "^0.11.2",
    "jest-junit": "^9.0.0",
    "jest-preset-angular": "^8.2.0",
    "protractor": "~5.4.0",
    "ts-jest": "^24.2.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.9.5"
  }
}


我尝试了node版本12.22.12和npm 6.14.16以及node 18.16.1 npm 6.14.16(新的npm版本会导致崩溃)
不幸的是,我对编程也是非常非常新的,这就是为什么我真的不知道该怎么做。
我还尝试删除所有node_modules、package-lock.json,并使用“npm cahce clean --force”和“npm install”,但都无济于事。

vs3odd8k

vs3odd8k1#

1.第一个月
1.删除node_modules文件夹
1.删除package-lock.json文件

  1. npm install
    对我很有效
igsr9ssn

igsr9ssn2#

错误消失了,我用Volta解决了它,我安装了Volta

"volta": {
    "node": "16.20.1"
  }

字符串
已经添加到package.json中,但上面的错误“dirname”仍然存在,将打开一个关于它的新帖子

相关问题