Not authorized on admin to execute command

NextJS使用mongoose连接数据库的时候报错 …

MongoServerError: Authentication failed.
at Connection.onMessage (/Users/net.cctv3.i/chnqoo-recollections-service/node_modules/mongodb/lib/cmap/connection.js:205:26)
at MessageStream.<anonymous> (/Users/net.cctv3.i/chnqoo-recollections-service/node_modules/mongodb/lib/cmap/connection.js:64:60)
at MessageStream.emit (node:events:518:28)
at processIncomingData (/Users/net.cctv3.i/chnqoo-recollections-service/node_modules/mongodb/lib/cmap/message_stream.js:117:16)
at MessageStream._write (/Users/net.cctv3.i/chnqoo-recollections-service/node_modules/mongodb/lib/cmap/message_stream.js:33:9)
at writeOrBuffer (node:internal/streams/writable:564:12)
at _write (node:internal/streams/writable:493:10)
at Writable.write (node:internal/streams/writable:502:10)
at Socket.ondata (node:internal/streams/readable:1007:22)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
ok: 0,
code: 18,
codeName: 'AuthenticationFailed',
connectionGeneration: 0,
[Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' }
}
阅读更多

NextJS加载不同环境的.env文件

NextJS默认加载的是.env.local,所以可以通过一个巧妙地办法,直接复制对应的文件到.env.local中,然后启动。

根目录添加不同环境的.env

➜  chnqoo-recollections-service git:(master) ✗ find . -type f -name ".env*"
./.env.production
./.env.local
./.env.alpha
./.env.staging
./.env.development
阅读更多

淘宝npm证书yarn报错(certificate has expired)

这尼玛大早上的来就给我报错,

error An unexpected error occurred: “https://registry.npm.taobao.org/@react-native-async-storage%2fasync-storage: certificate has expired”.

➜  chnqoo-recollections-mobile git:(main) yarn
yarn install v1.22.10
info No lockfile found.
[1/5] 🔍 Validating package.json...
[2/5] 🔍 Resolving packages...
error An unexpected error occurred: "https://registry.npm.taobao.org/@react-native-async-storage%2fasync-storage: certificate has expired".
info If you think this is a bug, please open a bug report with the information provided in "/Users/sunyg/chnqoo-recollections-mobile/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
阅读更多

Failed to clone nvm repo. Please report this!

Linux安装nvm报错,连接GitHub超时 …

root@VM-4-9-debian:~/nvm-0.39.7# ./install.sh
=> Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
fatal: unable to access 'https://github.com/nvm-sh/nvm.git/': Failed to connect to github.com port 443 af
ter 129382 ms: Couldn't connect to server
Failed to clone nvm repo. Please report this!
阅读更多