部署vue項目、安裝mongodb

一、node運行環境


1、npm install -g n


通過npm 全局安裝node


2、sudo n 8.16.0


設置node版本


Password:

install : node-v8.16.0

mkdir : /usr/local/n/versions/node/8.16.0

fetch : https://nodejs.org/dist/v8.16.0/node-v8.16.0-darwin-x64.tar.gz

######################################################################## 100.0%

installed : v8.16.0


3、node -v


v8.16.0


二、安裝mongodb


1、brew tap mongodb/brew


2、brew install mongodb-community


=> Installing mongodb-community from mongodb/brew

==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.5.tgz

######################################################################## 100.0%

==> Caveats

To have launchd start mongodb/brew/mongodb-community now and restart at login:

brew services start mongodb/brew/mongodb-community

Or, if you don't want/need a background service you can just run:

mongod --config /usr/local/etc/mongod.conf

==> Summary

/usr/local/Cellar/mongodb-community/4.2.5: 21 files, 305.9MB, built in 7 minutes 4 seconds

(base) mengfaniaodeMBP:homebrew-core mengfanxiao$ cat usr/local/etc/mongod.conf

cat: usr/local/etc/mongod.conf: No such file or directory

(base) mengfaniaodeMBP:homebrew-core mengfanxiao$ brew services start mongodb/brew/mongodb-community

==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)


3、啟動/停止


brew services start mongodb-community

brew services stop mongodb-community


4、配置


配置文件:/usr/local/etc/mongod.conf

日誌目錄路徑:/usr/local/var/log/mongodb

數據目錄路徑:/usr/local/var/mongodb


5、端口


默認端口

介紹

27017

mongod 和 mongos 實例的默認端口。你可以通過 port 或 --port 改變該端口。

27018

設置 --shardsvr 運行變量或在配置文件裡設置 clusterRole 為 shardsvr 時的默認端口。

27019

設置 --configsvr 運行變量或在配置文件中將 clusterRole 設置為 configsvr 時的默認端口。

28017

系統狀態網頁的默認端口。系統狀態網絡頁面永遠可以在比 port 大 1000 的端口反問。


三、問題梳理


1、環境問題


node -v


dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib

Referenced from: /usr/local/bin/node

Reason: image not found

Abort trap: 6


說明node相關庫已被損壞 需要重新安裝


卸載node

brew uninstall --ignore-dependencies node icu4c


Uninstalling /usr/local/Cellar/node/13.5.0... (4,663 files, 59.1MB)

node 12.12.0 is still installed.

Run `brew uninstall --force node` to remove all versions.


安裝node

brew install node

通過這種方式安裝的是最新版本的node 但很容易出現版本不兼容問題 所以不推薦這麼安裝 建議安裝node8 該版本比較穩定 很少出現與其他軟件不兼容情況


2、文件創建權限問題


==> Installing dependencies for node: icu4c

==> Installing node dependency: icu4c

==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/bottles/icu4c-64.2.mojave.bottle.tar.gz

######################################################################## 100.0%

==> Pouring icu4c-64.2.mojave.bottle.tar.gz

Error: Failed to create /usr/local/opt/icu4c

Things that depend on icu4c will probably not build.

Could not symlink .

/usr/local/opt is not writable.

==> Caveats


a、創建文件夾

sudo mkdir /usr/local/opt

b、root用戶賦予當前用戶操作該文件夾權限


此時該文件夾權限屬於root 給mengfanxiao賬戶賦予權限

chown -R mengfanxiao /usr/local/opt


3、插曲 springboot啟動問題


dea啟動spring-boot,報java.lang.NoClassDefFoundError: javax/servlet/ServletContext錯誤


org.springframework.boot

spring-boot-starter-tomcat

provided

把scope註釋掉即可


maven中三種classpath

編譯,測試,運行

1.compile:默認範圍,編譯測試運行都有效

2.provided:在編譯和測試時有效

3.runtime:在測試和運行時有效

4.test:只在測試時有效

5.system:在編譯和測試時有效,與本機系統關聯,可移植性差


4、環境不匹配問題


Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (79)qi


卸載重裝(最新版本的node-sass)即可:

npm uninstall node-sass -D

npm install node-sass -D


5、版本衝突問題 node和mongodb版本不兼容

[email protected] requires a peer of kerberos@~0.0


node -v v13.12.0

npm -v 6.14.4


gyp ERR! command "/usr/local/Cellar/node/13.12.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/mengfanxiao/Documents/project/company/wechain/questionnaire/node_modules/leveldown

gyp ERR! node -v v13.12.0

gyp ERR! node-gyp -v v5.1.0

gyp ERR! not ok

npm WARN [email protected] requires a peer of kerberos@~0.0 but none is installed. You must install peer dependencies yourself.


這種情況需要安裝node8


brew search node


==> Formulae

libbitcoin-node node node-sass node@12 nodebrew nodenv

llnode node-build node@10 node_exporter ✔ nodeenv


如果有node8

則 brew install node@8

然後brew link --overwrite --force node@8


沒有node8


npm install -g n

sudo n 8.16.0


安裝了node8版本


npm install

> [email protected] install /Users/mengfanxiao/Documents/project/company/wechain/new/questionnaire/node_modules/level/node_modules/leveldown

> prebuild-install || node-gyp rebuild

added 42 packages from 44 contributors in 20.79s


6、安裝mongodb問題


brew install mongodb

Error: No available formula with the name 'mongodb'

MongoDB不再是開源的了,並且已經從Homebrew中移除 #43770


安裝MongoDB社區服務器的最新可用生產版本(包括所有命令行工具)。這將安裝MongoDB 4.2.x:

$ brew install mongodb-community

安裝MongoDB社區服務器和命令行工具的最新4.2.x生產版本:

$ brew install [email protected]

安裝MongoDB社區服務器和命令行工具的最新4.0.x生產版本:

$ brew install [email protected]

安裝MongoDB社區服務器和命令行工具的最新3.6.x生產版本:

$ brew install [email protected]

僅安裝最新的mongoshell以連接到遠程MongoDB實例:

$ brew install mongodb-community-shell


分享到:


相關文章: