繁体   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