2017-08-05 83 views
1

我在嘗試安裝npm模塊時遇到奇怪的權限錯誤。我與sudo開始,所以我敢肯定,我做訪問,但由於某些原因,它一直有錯誤提示:安裝npm模塊時權限被拒絕

stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/joplin/node_modules/sqlite3/build'

我試着重新啓動我的電腦,並使用chmod創建一個目錄/usr/lib/node_modules/joplin 777,但它仍然不起作用。

$ sudo npm install -g joplin 
/usr/bin/joplin -> /usr/lib/node_modules/joplin/main.js 

> [email protected] install /usr/lib/node_modules/joplin/node_modules/sqlite3 
> node-pre-gyp install --fallback-to-build 

node-pre-gyp ERR! Tried to download(undefined): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.9/node-v48-linux-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v48 ABI) (falling back to source compile with node-gyp) 
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/joplin/node_modules/sqlite3/build' 
gyp ERR! stack  at Error (native) 
gyp ERR! System Linux 4.4.0-43-Microsoft 
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v48-linux-x64" 
gyp ERR! cwd /usr/lib/node_modules/joplin/node_modules/sqlite3 
gyp ERR! node -v v6.11.2 
gyp ERR! node-gyp -v v3.6.2 
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v48-linux-x64' (1) 
node-pre-gyp ERR! stack  at ChildProcess.<anonymous> (/usr/lib/node_modules/joplin/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29) 
node-pre-gyp ERR! stack  at emitTwo (events.js:106:13) 
node-pre-gyp ERR! stack  at ChildProcess.emit (events.js:191:7) 
node-pre-gyp ERR! stack  at maybeClose (internal/child_process.js:891:16) 
node-pre-gyp ERR! stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) 
node-pre-gyp ERR! System Linux 4.4.0-43-Microsoft 
node-pre-gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/joplin/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" 
node-pre-gyp ERR! cwd /usr/lib/node_modules/joplin/node_modules/sqlite3 
node-pre-gyp ERR! node -v v6.11.2 
node-pre-gyp ERR! node-pre-gyp -v v0.6.36 
node-pre-gyp ERR! not ok 

編輯

我也試過sudo npm i sqlite3 -g --build-from-source但得到了同樣的錯誤Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/sqlite3/build'所以它似乎是與sqlite3的。

回答

0

您需要回收.npm目錄的所有權。

sudo chown -R $(whoami) ~/.npm 

和需要node_modules目錄的寫權限:

sudo chown -R $(whoami) /usr/lib/node_modules