Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis-ci出现“module.js:549 throw err; ^ Error: Cannot find module './lib/source-map-generator'” #12

Open
shaobeichen opened this issue Jun 19, 2018 · 0 comments

Comments

@shaobeichen
Copy link
Owner

shaobeichen commented Jun 19, 2018

40757177-e41e14fe-64b9-11e8-88c2-bc0f7e1788b4 1

场景还原:本来只是为了修改几个小问题,本地也没有任何问题,但是push之后,travis-ci走构建的时候出现了错误,一度导致我有点小懵逼。

错误提示:

> node build/build.js
module.js:549
    throw err;
    ^
Error: Cannot find module './lib/source-map-generator'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/travis/build/[secure]/blog/node_modules/postcss-reduce-transforms/node_modules/source-map/source-map.js:6:30)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/travis/build/[secure]/blog/node_modules/postcss-reduce-transforms/node_modules/postcss/lib/previous-map.js:9:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `node build/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2018-06-19T09_42_10_772Z-debug.log

这其实是node_modules包里的问题,我在网上一番搜索,试着将本地的node_modules删除重新npm i,push之后发现还是这样的错,然后想着本地没有问题,那是不是ci的问题呢,这样就想到了travis-ci.yml里面的东西,只要将缓存node_modules的代码去除即可。

cache:
  directories:
    - node_modules

这样就不会缓存node_modules了,从而问题解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant