npm启动在带有TypeError的角度项目上失败

时间:2019-12-11 07:33:27

标签: angular npm

请参阅下面的堆栈跟踪。.

internal/modules/cjs/helpers.js:119
  if (content.charAt(0) === '#' && content.charAt(1) === '!') {
              ^

TypeError: content.charAt is not a function
    at stripShebang (internal/modules/cjs/helpers.js:119:15)
    at Module._compile (internal/modules/cjs/loader.js:877:13)
    at Object.require.extensions..ts (D:\workSpace\Azure\SOCH-UI\node_modules\angularcli\lib\bootstrap-local.js:25:14)   
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (D:\workSpace\Azure\SOCH-UI\node_modules\angularcli\packages\@angular\cli\bin\ng:21:1)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (D:\workSpace\Azure\SOCH-UI\node_modules\angularcli\bin\ng:9:1)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)

相同的代码与我的同事一起正常工作。此问题仅与我的系统有关,任何人都可以提出解决该问题的建议。

下面是错误日志

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:\\Users\\144958\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.13.3
3 info using node@v12.13.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle soch-ui@0.0.0~prestart: soch-ui@0.0.0
6 info lifecycle soch-ui@0.0.0~start: soch-ui@0.0.0
7 verbose lifecycle soch-ui@0.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle soch-ui@0.0.0~start: PATH: C:\Users\144958\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\workSpace\Azure\SOCH-UI\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\Common Files\Microsoft Shared\Microsoft Online Services;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\PuTTY\;C:\Windows\CCM;C:\Program Files\Git\cmd;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Open-Jdk-11.0.2\bin;C:\apache-maven-3.6.3\bin;C:\Users\144958\AppData\Roaming\npm;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\144958\AppData\Local\Microsoft\WindowsApps;C:\Open-Jdk-11.0.2\bin;C:\apache-maven-3.6.3\bin;
9 verbose lifecycle soch-ui@0.0.0~start: CWD: D:\workSpace\Azure\SOCH-UI
10 silly lifecycle soch-ui@0.0.0~start: Args: [ '/d /s /c', 'ng serve' ]
11 silly lifecycle soch-ui@0.0.0~start: Returned: code: 1  signal: null
12 info lifecycle soch-ui@0.0.0~start: Failed to exec start script
13 verbose stack Error: soch-ui@0.0.0 start: `ng serve`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\144958\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:210:5)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\144958\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:210:5)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid soch-ui@0.0.0
15 verbose cwd D:\workSpace\Azure\SOCH-UI
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\144958\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v12.13.1
19 verbose npm  v6.13.3
20 error code ELIFECYCLE
21 error errno 1
22 error soch-ui@0.0.0 start: `ng serve`
22 error Exit status 1
23 error Failed at the soch-ui@0.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
  

npm -v   6.13.3

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 8.3.20
Node: 12.13.1
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.20
@angular-devkit/core         8.3.20
@angular-devkit/schematics   8.3.20
@schematics/angular          8.3.20
@schematics/update           0.803.20
rxjs                         6.4.0

这是我当前的版本

1 个答案:

答案 0 :(得分:0)

使用npm i -g @angular/cli

安装angular cli