【发布时间】:2019-01-19 05:44:20
【问题描述】:
以下是我用来创建我的第一个 Angular 应用程序的步骤。
- 安装NodeJS
- 安装 VSCode
- 检查了我的 NodeJS 和 npm 版本
- 执行了
npm install -g @angular/cli,我在 VSCode 的集成终端中收到了以下日志(我相信这很好)
> PS C:\Users\Babar Baig\Desktop\Angular> npm install -g @angular/cli
C:\Users\Babar Baig\AppData\Roaming\npm\ng ->
C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current:{"os":"win32","arch":"x64"})
+ @angular/cli@6.1.3
updated 1 package in 75.927s
PS C:\Users\Babar Baig\Desktop\Angular>
- 执行
ng new appTwo来创建我的应用程序。以下是我收到的日志和错误。
PS C:\Users\Babar Baig\Desktop\Angular> ng new appTwo
CREATE appTwo/angular.json (3548 bytes)
CREATE appTwo/package.json (1312 bytes)
CREATE appTwo/README.md (1023 bytes)
CREATE appTwo/tsconfig.json (408 bytes)
CREATE appTwo/tslint.json (2805 bytes)
CREATE appTwo/.editorconfig (245 bytes)
CREATE appTwo/.gitignore (503 bytes)
CREATE appTwo/src/favicon.ico (5430 bytes)
CREATE appTwo/src/index.html (293 bytes)
CREATE appTwo/src/main.ts (370 bytes)
CREATE appTwo/src/polyfills.ts (3194 bytes)
CREATE appTwo/src/test.ts (642 bytes)
CREATE appTwo/src/styles.css (80 bytes)
CREATE appTwo/src/browserslist (375 bytes)
CREATE appTwo/src/karma.conf.js (964 bytes)
CREATE appTwo/src/tsconfig.app.json (170 bytes)
CREATE appTwo/src/tsconfig.spec.json (256 bytes)
CREATE appTwo/src/tslint.json (314 bytes)
CREATE appTwo/src/assets/.gitkeep (0 bytes)
CREATE appTwo/src/environments/environment.prod.ts (51 bytes)
CREATE appTwo/src/environments/environment.ts (642 bytes)
CREATE appTwo/src/app/app.module.ts (314 bytes)
CREATE appTwo/src/app/app.component.html (1141 bytes)
CREATE appTwo/src/app/app.component.spec.ts (995 bytes)
CREATE appTwo/src/app/app.component.ts (210 bytes)
CREATE appTwo/src/app/app.component.css (0 bytes)
CREATE appTwo/e2e/protractor.conf.js (752 bytes)
CREATE appTwo/e2e/tsconfig.e2e.json (213 bytes)
CREATE appTwo/e2e/src/app.e2e-spec.ts (302 bytes)
CREATE appTwo/e2e/src/app.po.ts (208 bytes)
npm WARN deprecated istanbul-lib-hook@1.2.1: 1.2.0 should have been a major version bump
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! path C:\Users\Babar Baig\Desktop\Angular\appTwo\node_modules\acorn\bin\acorn
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod 'C:\Users\Babar Baig\Desktop\Angular\appTwo\node_modules\acorn\bin\acorn'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Babar Baig\AppData\Roaming\npm-cache\_logs\2018-08-12T05_56_04_185Z-debug.log
Package install failed, see above.
PS C:\Users\Babar Baig\Desktop\Angular>
这是我在谷歌上搜索 Angular 的项目创建问题后所做的事情
- 卸载 NodeJS 和 Angular 并重新安装,但出现了同样的问题。
- 重启了我的 VSCode,但还是不行。
- 由于收到错误,通过
npm install -g acorn安装了 acorn。但同样的错误又发生了。
- 在我的本地文件夹“Angular”中使用
npm install @angular/cli安装了Angular cli,然后执行新项目命令ng new appTwo。没有收到任何进展。
我了解“npm”无法从路径“C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\acorn\bin\acorn”中找到“acorn”。 “node_modules”内没有“橡子”文件夹。但我不知道如何解决这个问题。
这里是命令运行的完整日志
0 info it worked if it ends with ok
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 'install',
1 verbose cli '-g',
1 verbose cli 'acorn' ]
2 info using npm@5.6.0
3 info using node@v8.11.3
4 verbose npm-session 0648b6c8ae8267c4
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 https://registry.npmjs.org/acorn 896ms (from cache)
8 silly pacote tag manifest for acorn@latest fetched in 954ms
9 silly install loadIdealTree
10 silly install cloneCurrentTreeToIdealTree
11 silly install loadShrinkwrap
12 silly install loadAllDepsIntoIdealTree
13 silly resolveWithNewModule acorn@5.7.1 checking installable status
14 silly currentTree npm
15 silly idealTree npm
15 silly idealTree `-- acorn@5.7.1
16 silly install generateActionsToTake
17 silly diffTrees action count 1
18 silly diffTrees add acorn@5.7.1
19 silly decomposeActions action count 8
20 silly decomposeActions fetch acorn@5.7.1
21 silly decomposeActions extract acorn@5.7.1
22 silly decomposeActions preinstall acorn@5.7.1
23 silly decomposeActions build acorn@5.7.1
24 silly decomposeActions install acorn@5.7.1
25 silly decomposeActions postinstall acorn@5.7.1
26 silly decomposeActions finalize acorn@5.7.1
27 silly decomposeActions refresh-package-json acorn@5.7.1
28 silly install executeActions
29 silly doSerial global-install 8
30 verbose correctMkdir C:\Users\Babar Baig\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
31 verbose lock using C:\Users\Babar Baig\AppData\Roaming\npm-cache\_locks\staging-51cfd9b4628f34cb.lock for C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\.staging
32 silly doParallel extract 8
33 silly extract acorn@5.7.1
34 silly pacote trying acorn@https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz by hash: sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==
35 silly pacote acorn@https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz extracted to C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\.staging\acorn-4f034420 by content address 24ms
36 silly doReverseSerial unbuild 8
37 silly doSerial remove 8
38 silly doSerial move 8
39 silly doSerial finalize 8
40 silly finalize C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\acorn
41 silly doParallel refresh-package-json 8
42 silly refresh-package-json C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\acorn
43 silly doParallel preinstall 8
44 silly preinstall acorn@5.7.1
45 info lifecycle acorn@5.7.1~preinstall: acorn@5.7.1
46 silly doSerial build 8
47 silly build acorn@5.7.1
48 info linkStuff acorn@5.7.1
49 silly linkStuff acorn@5.7.1 has C:\Users\Babar Baig\AppData\Roaming\npm\node_modules as its parent node_modules
50 silly linkStuff acorn@5.7.1 is part of a global install
51 silly linkStuff acorn@5.7.1 is installed into a global node_modules
52 silly linkStuff acorn@5.7.1 is installed into the top-level global node_modules
53 verbose linkBins acorn@5.7.1
54 verbose linkBins [ { acorn: './bin/acorn' },
54 verbose linkBins 'C:\\Users\\Babar Baig\\AppData\\Roaming\\npm',
54 verbose linkBins true ]
55 verbose linkMans acorn@5.7.1
56 verbose unlock done using C:\Users\Babar Baig\AppData\Roaming\npm-cache\_locks\staging-51cfd9b4628f34cb.lock for C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\.staging
57 verbose stack Error: ENOENT: no such file or directory, chmod 'C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\acorn\bin\acorn'
58 verbose cwd C:\Users\Babar Baig\Desktop\Angular
59 verbose Windows_NT 10.0.17134
60 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "acorn"
61 verbose node v8.11.3
62 verbose npm v5.6.0
63 error path C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\acorn\bin\acorn
64 error code ENOENT
65 error errno -4058
66 error syscall chmod
67 error enoent ENOENT: no such file or directory, chmod 'C:\Users\Babar Baig\AppData\Roaming\npm\node_modules\acorn\bin\acorn'
68 error enoent This is related to npm not being able to find a file.
69 verbose exit [ -4058, true ]
我从“\AppData\Roaming\npm-cache_logs”中找到它。任何帮助都将不胜感激,因为这是我第一次使用 Angular。
谢谢!
【问题讨论】:
-
试试这个然后评论结果
ng new test-project --skip-install然后cd test-project和npm install。 -
发生同样的错误。这是结果。 ... npm 错误!路径 C:\Users\Babar Baig\Desktop\Angular\test-project\node_modules\acorn\bin\acorn npm 错误!代码 ENOENT npm 错误! errno -4058 npm 错误!系统调用 chmod npm 错误! enoent ENOENT:没有这样的文件或目录,chmod 'C:\Users\Babar Baig\Desktop\Angular\test-project\node_modules\acorn\bin\acorn' npm ERR! enoent 这与 npm 找不到文件有关。 npm 错误!恩恩特
-
这一定是你的 npm 问题更新你的 npm。最新更新是 6.3.0
-
我安装了最新版本 (6.3.0) 的 npm,但我又遇到了同样的错误。 :(
-
你试过这个扔代理吗?