我有一個項目的設置是共享的node_modules目錄如下:是否有可能有項目
workspace
└cache
└node_modules
└gulp (and gulp-plugins, express etc.)
└nodejs
└node.exe
└project1
└gulpfile.js
└project2
└gulpfile.js
現在我想執行的項目目錄的gulpfile:
set NODE_PATH='C:\workspace\cache\node_modules\'
cd C:\workspace\project1\
C:\workspace\nodejs\node.exe C:\workspace\cache\node_modules\gulp\bin\gulp.js watch
我得到以下輸出:
[12:06:04] Local gulp not found in C:\workspace\project1
[12:06:04] Try running: npm install gulp
在這兩個項目文件夾中,gulp文件是相似的,並使用simi一組插件。我真的很想只有一次依賴(因爲可能有多達25個項目共享相同的node_modules)。 這是可能的設置,還是單獨的項目目錄需要有自己的node_modules文件夾?
其實你不需要在全局安裝gulp,你只需要命令行工具。我使用的命令(具有node.exe和gulp.js的完整路徑)是爲了防止必須使用全局安裝的gulp。 此方法在Windows上使用以下createlink命令: 'mklink/J node_modules .. \ SFBC \ node_modules' For the record;因爲我自己沒有想到這件事,所以我把頭撞在桌子上。從Linux/Mac環境來我不使用相同的方法適用於Windows。 – tuvokki