运行npm dist时出现"Permission denied"错误

9

我正在尝试部署我的静态网站,为此我正在尝试运行

npm run dist

运行哪个软件

copyfiles -f ./src/index.html ./src/favicon.ico ./dist

似乎出现了一个问题。
/Users/Alfred/React/newReactWebpack/reactWebpack/node_modules/.bin/webpack

文件被锁定,无法读写。我尝试过使用chmod 775和以sudo方式运行它,但都没有帮助。有谁知道可能出了什么问题吗?

谢谢!


运行命令后控制台的输出:

templateApp@0.0.1 dist /Users/Alfred/React/newReactWebpack/reactWebpack
npm run copy & webpack --env=dist
sh: /Users/Alfred/React/newReactWebpack/reactWebpack/node_modules/.bin/webpack: Permission denied

npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/Cellar/node/6.2.2/bin/node" "/usr/local/bin/npm" "run" "dist"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! templateApp@0.0.1 dist: npm run copy & webpack --env=dist
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the templateApp@0.0.1 dist script 'npm run copy & webpack --env=dist'.
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 templateApp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run copy & webpack --env=dist
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs templateApp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls templateApp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/Alfred/React/newReactWebpack/reactWebpack/npm-debug.log

templateApp@0.0.1 copy /Users/Alfred/React/newReactWebpack/reactWebpack
copyfiles -f ./src/index.html ./src/favicon.ico ./dist
sh: /Users/Alfred/React/newReactWebpack/reactWebpack/node_modules/.bin/copyfiles: Permission denied

npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/Cellar/node/6.2.2/bin/node" "/usr/local/bin/npm" "run" "copy"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! templateApp@0.0.1 copy: copyfiles -f ./src/index.html ./src/favicon.ico ./dist
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the templateApp@0.0.1 copy script 'copyfiles -f ./src/index.html ./src/favicon.ico ./dist'.
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 templateApp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! copyfiles -f ./src/index.html ./src/favicon.ico ./dist
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs templateApp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls templateApp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/Alfred/React/newReactWebpack/reactWebpack/npm-debug.log

1
你尝试过执行 rm -rf node_modules,然后执行 npm cache clear,最后执行 npm install 吗? - RyanZim
1个回答

15
如果你运行chmod 775 /Users/Alfred/React/newReactWebpack/reactWebpack/node_modules/.bin/webpack,它只会改变/webpack的权限。 尝试运行chmod 775 -R /Users/Alfred/React,这会递归更改/React下所有文件和文件夹的权限。 如果这样不起作用,请尝试使用chown将其所有者更改为你的用户名。 参考:chmod 775 on a folder but not all files under that folder

2
在Mac上,-R标志需要放在前面... chmod -R 775 ./dir - DigitalDesignDj

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