環境:
將 windows 資料夾共用給 linux 虛擬機,
然後在 linux 上,於 windows 的共用資料夾下安裝 express
$ npm install express --save npm WARN rollback Rolling back send@0.16.2 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/home/web/win/aa/nodejs/node_modules/send' npm WARN rollback Rolling back mime@1.4.1 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/home/web/win/aa/nodejs/node_modules/mime' npm WARN rollback Rolling back serve-static@1.13.2 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/home/web/win/aa/nodejs/node_modules/serve-static' npm WARN rollback Rolling back express@4.16.3 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/home/web/win/aa/nodejs/node_modules/express' npm WARN chat@0.0.1 No repository field. npm ERR! path ../mime/cli.js npm ERR! code ENOTSUP npm ERR! errno -95 npm ERR! syscall symlink npm ERR! nospc ENOTSUP: operation not supported on socket, symlink '../mime/cli.js' -> '/home/win/nodejs/node_modules/.bin/mime' npm ERR! nospc There appears to be insufficient space on your system to finish. npm ERR! nospc Clear up some disk space and try again. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2018-03-26T09_28_59_107Z-debug.log
解決:
因 windows 共享的資料夾不能建立符號連結(symlinks),所以須加上 --no-bin-links 參數
$ npm install express --no-bin-links --save
參考:
- https://docs.npmjs.com/cli/install
The --no-bin-links argument will prevent npm from creating symlinks for any binaries the package might contain. - https://github.com/npm/npm/issues/7094
npm ERR! Error: UNKNOWN, symlink '../user-home/cli.js' - https://stackoverflow.com/questions/39098812/npm-install-when-to-use-no-bin-links
npm install: when to use --no-bin-links?
[使用 --no-bin-links 衍生的問題]
如果 在 linux 上掛載 windows 上的專案資料夾,在 linux 安裝時,不得已使用 --no-bin-links,雖可以順利安裝。但因為在 linux 上,node_modules/.bin 資料夾底下是檔案連結,連結到對應的實際套件底下,而掛載的 windows 無法建議檔案連結,所以 node_modules/.bin 底下會沒東西,若專案需要用到 node_modules/.bin 底下的檔案來執行,會無法運作。
參考:
- https://github.com/yarnpkg/yarn/issues/4782
--no-bin-links options skip the .bin folder creation - https://segmentfault.com/q/1010000020983915
node_modules 有的没有.bin文件夹有的有是什么情况?
沒有留言:
張貼留言