我对 Angular 不太熟悉。我正在从 CLI 生成一个新的 Angular 应用程序,但收到 npm 错误。
ubox18@ubox18:~/ng-apps$ ng new techadda
? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? CSS
CREATE techadda/README.md (1025 bytes)
CREATE techadda/.editorconfig (246 bytes)
CREATE techadda/.gitignore (629 bytes)
CREATE techadda/angular.json (3825 bytes)
CREATE techadda/package.json (1307 bytes)
CREATE techadda/tsconfig.json (435 bytes)
CREATE techadda/tslint.json (1621 bytes)
CREATE techadda/src/favicon.ico (5430 bytes)
CREATE techadda/src/index.html (295 bytes)
CREATE techadda/src/main.ts (372 bytes)
CREATE techadda/src/polyfills.ts (2841 bytes)
CREATE techadda/src/styles.css (80 bytes)
CREATE techadda/src/test.ts (642 bytes)
CREATE techadda/src/browserslist (388 bytes)
CREATE techadda/src/karma.conf.js (1021 bytes)
CREATE techadda/src/tsconfig.app.json (166 bytes)
CREATE techadda/src/tsconfig.spec.json (256 bytes)
CREATE techadda/src/tslint.json (244 bytes)
CREATE techadda/src/assets/.gitkeep (0 bytes)
CREATE techadda/src/environments/environment.prod.ts (51 bytes)
CREATE techadda/src/environments/environment.ts (662 bytes)
CREATE techadda/src/app/app-routing.module.ts (245 bytes)
CREATE techadda/src/app/app.module.ts (393 bytes)
CREATE techadda/src/app/app.component.css (0 bytes)
CREATE techadda/src/app/app.component.html (1152 bytes)
CREATE techadda/src/app/app.component.spec.ts (1101 bytes)
CREATE techadda/src/app/app.component.ts (212 bytes)
CREATE techadda/e2e/protractor.conf.js (752 bytes)
CREATE techadda/e2e/tsconfig.e2e.json (213 bytes)
CREATE techadda/e2e/src/app.e2e-spec.ts (637 bytes)
CREATE techadda/e2e/src/app.po.ts (251 bytes)
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/713bc9a4'
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/587a6d34'
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/d24ecd3c'
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/183be234'
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/65378392'
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/c2e18bc1'
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/19e9a26f'
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/14846b9a'
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/1d1b4940'
Unhandled rejection Error: EACCES: permission denied, open '/home/ubox18/.npm/_cacache/tmp/fb3fc3bb'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
Package install failed, see above.
任何人都可以帮忙解决这个错误吗?我搜索并浏览了这个答案:npm ERR cb() never called但这不起作用。
最佳答案
将所有权授予 npm,如下所示:
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
或者尝试
sudo chown -R $(whoami) ~/.npm
关于node.js - 从 cli 生成新的 Angular 应用程序引发 npm 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55708045/