NPM이 종속성을 설치할 수 없음-잠기지 않은 것을 잠금 해제하려고했습니다.
package.json 파일에서 npm 설치를 실행하려고했지만 많은 문제가 있습니다. 모든 종속성에 대해 "오류 : 잠기지 않은 XXX의 잠금을 해제하려고합니다"라고 계속 표시됩니다. 다음 중 하나입니다.
Error: Attempt to unlock tbd@~0.6.4, which hasn't been locked
at unlock (/usr/local/lib/node_modules/npm/lib/cache.js:1304:11)
at cb (/usr/local/lib/node_modules/npm/lib/cache.js:646:5)
at /usr/local/lib/node_modules/npm/lib/cache.js:655:20
at /usr/local/lib/node_modules/npm/lib/cache.js:1290:7
at /usr/local/lib/node_modules/npm/node_modules/lockfile/lockfile.js:167:38
at OpenReq.Req.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:144:5)
at OpenReq.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:64:22)
at Object.oncomplete (fs.js:107:15)
sudo로 실행하려고하면 더 많은 패키지가 설치되기 시작하지만 새로운 오류가 대신 나타납니다.
> chokidar@0.8.1 postinstall /Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/chokidar
> node setup-deps.js
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
node.js:811
var cwd = process.cwd();
^
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:811:23)
at startup (node.js:58:13)
at node.js:902:3
npm ERR! error rolling back Error: ENOTEMPTY, rmdir '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q'
npm ERR! error rolling back karma@0.10.9 { [Error: ENOTEMPTY, rmdir '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q']
npm ERR! error rolling back errno: 53,
npm ERR! error rolling back code: 'ENOTEMPTY',
npm ERR! error rolling back path: '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q' }
npm ERR! Error: ENOENT, chown '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/socket.io/lib/socket.io.js'
최근에 노드 및 npm 설치를 업데이트했습니다. 아마도 그것은 그것과 관련이있을 것입니다. 또한 대부분의 개발 작업은 사무실에서 이루어졌으며 현재는 VPN을 통해 작업하고 있습니다.
어떤 아이디어?
photusenigma에 따라 https://github.com/npm/npm/issues/4815
터미널 창에서 다음 명령을 실행하십시오 (참고-$ USER 부분을 바꾸지 마십시오 ... 사용자를 얻는 Linux 명령입니다!) :
sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local/lib/node_modules
... 그리고 ... 맥과 같은 컴퓨터를 사용하고 있는데이 명령을 실행 한 후에도 오류가 계속 표시되면 마지막 명령을 실행하면됩니다. (이 작업을 수행하기 전에 테스트 해 보는 것이 좋습니다. 실제로 필요한 것 같지 않으면 ENTIRE / usr / local 디렉토리의 권한을 변경하는 것을 좋아하지 않습니다!)
sudo chown -R $USER /usr/local
오늘 오후에 동료와 함께 일하면서 문제가 무엇인지 알아 냈습니다. 내 홈 디렉토리의 ".npm"폴더는 본인이 아닌 루트 사용자가 소유했습니다. 그 원인이 무엇인지 잘 모르겠습니다. 어쩌면 node 또는 npm을 루트 관리자로 설치했을 수도 있습니다. 어쨌든 방금 실행 sudo chown -R [username] .npm
했고 마침내 npm install
내 프로젝트에서 명령을 다시 실행할 수있었습니다 !
필자의 경우 문제는 HOME 디렉토리가없는 사용자로 npm을 호출했기 때문에 다음 명령이 실패합니다.
sudo -u someUser npm install
해결책은 someUser
쓰기 권한이 있는 HOME 디렉토리를 제공하는 것입니다 .
sudo -u someUser HOME=/some/directory npm install
동일한 문제가 있었으며 허용 된 답변에 따라 권한을 변경하여 수정했습니다.
sudo chown -R $USER ~/.npm
그러나 두 번째 명령은 시스템 리소스 ( sudo chown -R $USER /usr/local/lib/node_modules
) 의 권한을 다운 그레이드하므로 피해야합니다 . 좋은 생각이 아닙니다.
레코드 : "usr"은 Unix System Resources 를 /usr/local
나타냅니다 .
이 중 어느 것도 나를 위해 일하지 않았습니다. 다음을 수행하여 문자 그대로 루트로 실행해야했습니다.
sudo su -
sudo npm install forever -g
그런 다음 패키지가 Linux Ubuntu 14.04에 설치되었습니다.
다음 명령은 권한 문제를 해결해야합니다.
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
공식적으로 권장되는 다른 솔루션에 대해 읽을 수 있습니다.
https://docs.npmjs.com/getting-started/fixing-npm-permissions
My solution:
sudo chown -R $USER /usr/local/lib/node_modules/NAMEOFMODULE
in my case was :
sudo chown -R $USER /usr/local/lib/node_modules/appium/
But I was getting the same problem, finally after
npm cache clean
it worked !
I had the same problem and tried to fix the permission/ownership of npm related files and directories for hours but had no luck with that.
Suddenly I found that I had ~/.npmrc
file with cache
entry pointing to a non-existing directory. Removed that cache
property to use the default cache location and now it's solved.
Disclaimer
I am a Windows user. However, my team and I have come across a number of issues regarding npm installaion errors.
Problems
The following is a list of lessons learned and a possible radical solution that has always rescued us:
- node_modules, the npm local installation directory becomes protected from modification by a shortcoming of the OS such as the inability to process paths longer than 255 characters.
- If the folder is erased by means of a command line tool it may still appear as if the folder exists in the explorer that when trying to access it gives a number of permission errors.
- Depending on your antivirus and/or local policy manager you may be able to create the node_modules folder and later relegated access or permissions to it resulting in a number of installation errors.
Enable npm logs to gain further insight into possible problems with:
npm install --loglevel verbose
Radical
Install rimraf globally
npm install rimraf -g
Run rimraf on node_modules:
rimraf yourDir/node_modules
Then try running:
npm install
Warning!
Or lack there of. Be extremely careful about what follows the command rimraf
. There are no warnings, no prompts, there is nothing. It simply erases the directory from the phase of the earth clean, as if it was never there. Try it at your own risk.
'IT' 카테고리의 다른 글
콘 다를 실행하는 방법? (0) | 2020.05.12 |
---|---|
동적 (C # 4)과 var의 차이점은 무엇입니까? (0) | 2020.05.12 |
Instant와 LocalDateTime의 차이점은 무엇입니까? (0) | 2020.05.12 |
TMUX에서 창을 종료하는 방법? (0) | 2020.05.12 |
jQuery가 아닌 크로스 브라우저 JavaScript 맨 위로 스크롤 (0) | 2020.04.25 |