NPM Start – 权限错误

3

当我尝试运行“npm start”时,出现了错误。看起来我有一些权限问题,但我不知道如何解决它,而且我可能搞砸了一些东西...所以最好删除Node、NPM和其他可能引起问题的所有内容...

这是我得到的错误信息。也许有人可以帮忙...提前感谢!

npm start

> angular-quickstart@1.0.0 start /Users/thomasveit/quickstart
> tsc && concurrently "tsc -w" "lite-server" 

error TS5033: Could not write file '/Users/thomasveit/quickstart/app/app.component.js': EACCES: permission denied, open '/Users/thomasveit/quickstart/app/app.component.js'
error TS5033: Could not write file '/Users/thomasveit/quickstart/app/app.component.js.map': EACCES: permission denied, open '/Users/thomasveit/quickstart/app/app.component.js.map'
error TS5033: Could not write file '/Users/thomasveit/quickstart/app/app.component.spec.js': EACCES: permission denied, open '/Users/thomasveit/quickstart/app/app.component.spec.js'
error TS5033: Could not write file '/Users/thomasveit/quickstart/app/app.component.spec.js.map': EACCES: permission denied, open '/Users/thomasveit/quickstart/app/app.component.spec.js.map'
error TS5033: Could not write file '/Users/thomasveit/quickstart/app/app.module.js': EACCES: permission denied, open '/Users/thomasveit/quickstart/app/app.module.js'
error TS5033: Could not write file '/Users/thomasveit/quickstart/app/app.module.js.map': EACCES: permission denied, open '/Users/thomasveit/quickstart/app/app.module.js.map'
error TS5033: Could not write file '/Users/thomasveit/quickstart/app/main.js': EACCES: permission denied, open '/Users/thomasveit/quickstart/app/main.js'
error TS5033: Could not write file '/Users/thomasveit/quickstart/app/main.js.map': EACCES: permission denied, open '/Users/thomasveit/quickstart/app/main.js.map'
error TS5033: Could not write file '/Users/thomasveit/quickstart/e2e/app.e2e-spec.js': EACCES: permission denied, open '/Users/thomasveit/quickstart/e2e/app.e2e-spec.js'
error TS5033: Could not write file '/Users/thomasveit/quickstart/e2e/app.e2e-spec.js.map': EACCES: permission denied, open '/Users/thomasveit/quickstart/e2e/app.e2e-spec.js.map'
app/app.component.spec.ts(4,50): error TS2307: Cannot find module '@angular/core/testing'.
app/app.component.spec.ts(5,30): error TS2307: Cannot find module '@angular/platform-browser'.
app/app.component.spec.ts(6,30): error TS2307: Cannot find module '@angular/core'.
app/app.component.spec.ts(9,1): error TS2304: Cannot find name 'describe'.
app/app.component.spec.ts(14,3): error TS2304: Cannot find name 'beforeEach'.
app/app.component.spec.ts(21,3): error TS2304: Cannot find name 'beforeEach'.
app/app.component.spec.ts(27,3): error TS2304: Cannot find name 'it'.
app/app.component.spec.ts(27,39): error TS2304: Cannot find name 'expect'.
app/app.component.spec.ts(29,3): error TS2304: Cannot find name 'it'.
app/app.component.spec.ts(32,5): error TS2304: Cannot find name 'expect'.
app/app.component.ts(1,27): error TS2307: Cannot find module '@angular/core'.
app/app.module.ts(1,31): error TS2307: Cannot find module '@angular/core'.
app/app.module.ts(2,31): error TS2307: Cannot find module '@angular/platform-browser'.
app/main.ts(1,40): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.
e2e/app.e2e-spec.ts(1,38): error TS2307: Cannot find module 'protractor'.
e2e/app.e2e-spec.ts(3,1): error TS2304: Cannot find name 'describe'.
e2e/app.e2e-spec.ts(7,3): error TS2304: Cannot find name 'beforeEach'.
e2e/app.e2e-spec.ts(11,3): error TS2304: Cannot find name 'it'.
e2e/app.e2e-spec.ts(12,5): error TS2304: Cannot find name 'expect'.

npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! angular-quickstart@1.0.0 start: `tsc && concurrently "tsc -w" "lite-server" `
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the angular-quickstart@1.0.0 start script 'tsc && concurrently "tsc -w" "lite-server" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc && concurrently "tsc -w" "lite-server" 
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular-quickstart
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! path npm-debug.log.884692043
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open

npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.884692043'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, open 'npm-debug.log.884692043'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'open',
npm ERR!   path: 'npm-debug.log.884692043' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/thomasveit/quickstart/npm-debug.log
5个回答

4
这似乎是您设置项目的目录权限问题。我认为您需要更新权限以允许写入: /Users/thomasveit/quickstart/
最简单的方法可能是创建一个新目录,因为这个目录可能有点问题。设置权限(递归)为全开放,然后在再次尝试运行之前将所有文件复制到新位置。或者,您可以在当前目录上尝试相同的操作。
如果您想要在Windows Explorer上设置文件夹权限,可以通过以下方式进行: 右键单击该文件夹 -> 属性 -> 安全选项卡 勾选左下角的复选框"替换所有子项权限项为此对象的可继承权限项"
或者,您可以通过命令行对文件夹进行操作,类似于这样: icacls "C:\Users\thomasveit\quickstart\" /t /g
如果您试图找出导致问题的原因,还可以尝试运行"npm run lite",以查看服务器是否可以启动?而不是运行"npm start"中的并发命令,这会增加更多关于错误的混淆可能性。

1
你能提供你的package.json文件的副本吗?因为看起来好像你没有正确地设置某些内容。

这是来自Angular快速入门项目的内容:https://github.com/angular/quickstart/blob/master/package.json我没有改过任何东西... - Tommy

0
当我在一个与TypeScript尝试创建的必需目录之一相同的位置有一个同名文件(例如:./dist)时,我遇到了相同的错误。
例如,一旦我在typscriptconfig.json中将设置outFile:“dist”切换为outDir:“dist”,然后我遇到了完全相同的问题。
删除dist文件后,一切都恢复正常。
结论:查看具有与其中一个所需TypeScript文件夹相同名称和位置的文件,并删除/重命名这些文件。

0

谢谢您的答案!我进行了npm清理缓存并安装了Node 7.1.0,然后它又可以正常工作了...


0

我进入了错误列表中的每个文件,在文件资源管理器中右键单击,然后更改了它们的权限。错误消失了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接