2019-09-26
npm install 一直顯示 Refusing to install package with name
今天安裝時遇到了很神奇的事情
$ docker run --rm -v `pwd`:/app -w /app node:12-alpine npm i config
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "abc" under a package
npm ERR! also called "abc". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR!
npm ERR! For more information, see:
npm ERR! <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-09-26T13_22_56_213Z-debug.log
上述的 abc
明顯是 package.json 裡面的 name
但問題是,無論我改成任何名字,都還是一樣的錯誤
懷疑是 npm cache 機制出了問題,於是嘗試了
docker run --rm -v `pwd`:/app -w /app node:12-alpine npm cache clean --force
結果沒用,還是同樣錯誤訊息
接下來又重新創了個新專案
mkdir a
cd a
npm init
npm i config
可以正常運作,看來確實是緩存有問題,只是不知道要去哪邊清理
最後突發想法試了一下
docker run --rm -v `pwd`:/app -w /app node:12-alpine npm i config@3
=_= 成功了!