簡體   English   中英

NPM node_modules / .bin符號鏈接

[英]NPM node_modules/.bin symlinks

我有一個NodeJS應用程序,使用CI工具(Travis或CodeShip)后,node_modules / .bin文件夾中的符號鏈接出現問題。

如果我跑...

npm安裝

在新的ubuntu服務器或我的開發機上,我的node_modules / .bin文件夾如下所示:

lrwxrwxrwx 1 ubuntu ubuntu 19 May 10 14:35 gulp -> ../gulp/bin/gulp.js
lrwxrwxrwx 1 ubuntu ubuntu 25 May 10 14:35 nodemon -> ../nodemon/bin/nodemon.js
lrwxrwxrwx 1 ubuntu ubuntu 32 May 10 14:35 randomstring -> ../randomstring/bin/randomstring

但是,如果我通過TravisCI或CodeShip運行該項目,則node_modules / .bin文件夾似乎具有扁平化的符號鏈接,僅剩下bin文件:

-rwxrwxr-x  1 ubuntu ubuntu 5384 Jan 31 20:55 gulp
-rwxrwxr-x  1 ubuntu ubuntu  441 Apr 29 20:31 nodemon
-rwxrwxr-x  1 ubuntu ubuntu  896 Feb 10 14:14 randomstring

然后,問題在於npm二進制文件無法解析它們自己的內部依賴性,因為該bin不在其npm module文件夾的上下文中執行(例如,node_modules / nodemon):

> nodemon app.js

module.js:327
    throw err;
    ^

Error: Cannot find module '../lib/cli'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/ubuntu/rawfiles/node_modules/.bin/nodemon:3:11)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)

npm ERR! Linux 3.13.0-74-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! app@0.0.1 start: `nodemon app.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the app@0.0.1 start script 'nodemon app.js'.
npm ERR! This is most likely a problem with the app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     nodemon app.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ubuntu/rawfiles/npm-debug.log

因此,嘗試通過TravisCI / CodeShip進行部署后,我必須運行...

rm -R node_modules

npm安裝

使任何npm腳本(例如npm start)運行。

是否有我不知道的配置項會使Travis / CodeShip展平/忽略符號鏈接? 我已經研究了一段時間,但沒有找到答案。

不幸的是,我無法為缺少的符號鏈接找到確切的答案。 但是我通過添加以下內容解決了手頭的問題:

npm install gulp

npm install nodemon

到修復符號鏈接的BeforeInstall部署掛鈎。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM