我使用了此命令
ng new hello
以Visual Studio代码创建一个新项目。它会创建所有文件,但是在安装软件包时会停止并显示错误。我将整个错误复制到下面:
PS E:\Angular> ng new hello
? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? CSS
CREATE hello/angular.json (3558 bytes)
CREATE hello/package.json (1281 bytes)
CREATE hello/README.md (1022 bytes)
CREATE hello/tsconfig.json (489 bytes)
CREATE hello/tslint.json (3125 bytes)
CREATE hello/.editorconfig (274 bytes)
CREATE hello/.gitignore (631 bytes)
CREATE hello/browserslist (429 bytes)
CREATE hello/karma.conf.js (1017 bytes)
CREATE hello/tsconfig.app.json (210 bytes)
CREATE hello/tsconfig.spec.json (270 bytes)
CREATE hello/src/favicon.ico (948 bytes)
CREATE hello/src/index.html (291 bytes)
CREATE hello/src/main.ts (372 bytes)
CREATE hello/src/polyfills.ts (2835 bytes)
CREATE hello/src/styles.css (80 bytes)
CREATE hello/src/test.ts (753 bytes)
CREATE hello/src/assets/.gitkeep (0 bytes)
CREATE hello/src/environments/environment.prod.ts (51 bytes)
CREATE hello/src/environments/environment.ts (662 bytes)
CREATE hello/src/app/app-routing.module.ts (246 bytes)
CREATE hello/src/app/app.module.ts (393 bytes)
CREATE hello/src/app/app.component.html (25755 bytes)
CREATE hello/src/app/app.component.spec.ts (1056 bytes)
CREATE hello/src/app/app.component.ts (209 bytes)
CREATE hello/src/app/app.component.css (0 bytes)
CREATE hello/e2e/protractor.conf.js (808 bytes)
CREATE hello/e2e/tsconfig.json (214 bytes)
CREATE hello/e2e/src/app.e2e-spec.ts (638 bytes)
CREATE hello/e2e/src/app.po.ts (301 bytes)
| Installing packages...npm WARN deprecated tslint@6.1.2: TSLint has been deprecated in favor of
ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.
npm WARN deprecated request@2.88.2: request has been deprecated, see
https://github.com/request/request/issues/3142
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with
15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure
binaries. Upgrade to fsevents 2.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
E:\Angular\hello\parser -> E:\Angular\hello\node_modules\@babel\parser\bin\babel-parser.js
E:\Angular\hello\acorn -> E:\Angular\hello\node_modules\acorn\bin\acorn
E:\Angular\hello\ansi-html -> E:\Angular\hello\node_modules\ansi-html\bin\ansi-html
E:\Angular\hello\atob -> E:\Angular\hello\node_modules\atob\bin\atob.js
E:\Angular\hello\cssesc -> E:\Angular\hello\node_modules\cssesc\bin\cssesc
E:\Angular\hello\esparse -> E:\Angular\hello\node_modules\esprima\bin\esparse.js
E:\Angular\hello\esvalidate -> E:\Angular\hello\node_modules\esprima\bin\esvalidate.js
E:\Angular\hello\image-size -> E:\Angular\hello\node_modules\image-size\bin\image-size.js
E:\Angular\hello\jsesc -> E:\Angular\hello\node_modules\jsesc\bin\jsesc
E:\Angular\hello\loose-envify -> E:\Angular\hello\node_modules\loose-envify\cli.js
E:\Angular\hello\miller-rabin -> E:\Angular\hello\node_modules\miller-rabin\bin\miller-rabin
E:\Angular\hello\mime -> E:\Angular\hello\node_modules\mime\cli.js
E:\Angular\hello\blocking-proxy -> E:\Angular\hello\node_modules\blocking-proxy\built\lib\bin.js
E:\Angular\hello\json5 -> E:\Angular\hello\node_modules\json5\lib\cli.js
E:\Angular\hello\mkdirp -> E:\Angular\hello\node_modules\mkdirp\bin\cmd.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2
(node_modules\rollup\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted
{"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN notsup Unsupported engine for watchpack-chokidar2@2.0.0: wanted: {"node":"<8.10.0"}
(current: {"node":"12.18.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2@2.0.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\watchpack-
chokidar2\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted
{"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\webpack-dev-
server\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted
{"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code EEXIST
npm ERR! path E:\Angular\hello\node_modules\browserslist\cli.js
npm ERR! dest E:\Angular\hello\browserslist
npm ERR! EEXIST: file already exists, cmd shim 'E:\Angular\hello\node_modules\browserslist\cli.js' -
> 'E:\Angular\hello\browserslist'
npm ERR! File exists: E:\Angular\hello\browserslist
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dell\AppData\Roaming\npm-cache\_logs\2020-06-05T18_42_48_450Z-debug.log
× Package install failed, see above.
The Schematic workflow failed. See above.
我尝试重新安装所有内容。我也尝试过更新我的角度cli。我也尝试过卸载angular cli并清理缓存,然后重新安装angular cli。但是,这些都不起作用。 我在Google上搜索了很多,但感到没有任何工作。我已经尝试解决此错误已有一个星期了。我不知道该怎么办 任何帮助,将不胜感激。
更新:
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module
'C:\Users\Dell\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Function.executeUserEntryPoint [as runMain]
(internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
答案 0 :(得分:0)
删除node_modules目录。
再次运行npm install
。
希望对您有帮助。
答案 1 :(得分:0)
如果已安装,请卸载angular cli
npm uninstall -g @angular/cli
删除C:\Users\Dell\AppData\Roaming\npm\node_modules\@angular
文件夹,如果该文件夹在卸载后仍然存在
全局重新安装angular-cli
npm install -g @angular/cli
答案 2 :(得分:0)
这是我的笔记(来自cmd):
"expo": "~ 36.0.0"
//必须具有10.9.0或更高版本
node -v
npm install -g @angular/cli