weixin_39880490
weixin_39880490
2021-01-12 05:15

node_modules folder inside my test folder confuses npm

When I run npm test in mymodule/test, /esm v0.19.7 (in Node.js v6.12.3, npm v5.6.0, Ubuntu 14.04.5 LTS trusty) creates a folder mymodule/test/node_modules. When I run the same command again,

npm ERR! enoent ENOENT: no such file or directory, open '/…/mymodule/test/package.json' npm ERR! enoent This is related to npm not being able to find a file.

because npm seems to expect my project only has a top-level node_modules. Which I'd also prefer, in order to have less entries in my .gitignore. Could you make /esm create the node_modules for its cache next to my package.json, instead of next to each file that transforms?

该提问来源于开源项目:standard-things/esm

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

12条回答

  • weixin_39880490 weixin_39880490 3月前

    Thanks! I upgraded the dependency version in esmod-pmb, now the portmap-parser tests work repeatedly out of the box in fresh installs. :+1:

    点赞 评论 复制链接分享
  • weixin_39797758 weixin_39797758 3月前

    I'm guessing you have an .esmrc config in your test folder or a package.json there? You can modify the config with the cache option. I'll look into only creating the cache by default in a package root. If you have a repro repo I could double check.

    点赞 评论 复制链接分享
  • weixin_39880490 weixin_39880490 3月前
    点赞 评论 复制链接分享
  • weixin_39880490 weixin_39880490 3月前

    Might be noteworthy that the effect doesn't happen in the test folder of esmod-pmb itself.

    点赞 评论 复制链接分享
  • weixin_39797758 weixin_39797758 3月前

    Okay, this is interesting!

    -pmb You are my kind of dev. I ❤️ the unique things you're attempting to do with /esm. I'm going to dig in, fix the issue, and then add this as a test scenario so we don't regress it in the future!

    Update:

    Welp, I solved everything but the folder location bit.

    点赞 评论 复制链接分享
  • weixin_39880490 weixin_39880490 3月前

    Thanks! :-) Yeah that

    TypeError: Cannot read property 'options' of null

    started to happen when I upgraded to latest /std (via esmod-pmb v0.1.2). I had no idea why, but didn't care yet because the npm confusion still occurrs as described.

    点赞 评论 复制链接分享
  • weixin_39797758 weixin_39797758 3月前

    Patches:

    Fix related fails: https://github.com/standard-things/esm/commit/0d7729e42e8b1fb62eeb276c049495c3af377568, https://github.com/standard-things/esm/commit/ec0a81fdd8a9a53bbd16f0d675905f2726dda372, https://github.com/standard-things/esm/commit/94c7f559beafafec495a0090391e0998cf93ea8c Fix cache folder: https://github.com/standard-things/esm/commit/5f3829cb3e0c88c34707f6b69e407a8c7c33c16a, https://github.com/standard-things/esm/commit/e21545e15cbe9f02aed944c6c97eb182b3f01d34

    点赞 评论 复制链接分享
  • weixin_39880490 weixin_39880490 3月前

    Nice! So does it work now? Could you build a new version? I tried that myself, but npm's progress bar for installing the dev deps moves really slow.

    点赞 评论 复制链接分享
  • weixin_39797758 weixin_39797758 3月前

    I'm still writing a test. I'll publish a release by this evening.

    点赞 评论 复制链接分享
  • weixin_39880490 weixin_39880490 3月前

    Meanwhile I managed to build the new master version and it works for me. Thanks again!

    点赞 评论 复制链接分享
  • weixin_39880490 weixin_39880490 3月前

    To save fellow Europeans from license compatibility considerations: I grant permission to use and distribute adaptations of esmod-pmb v0.1.1 and/or v0.1.2 under the MIT license in his name.

    Would be nice if you could include info about the base material in your test/fixture/scenario/portmap-parser/node_modules/esmod-pmb/package.json though. Serving suggestion

    点赞 评论 复制链接分享
  • weixin_39797758 weixin_39797758 3月前

    Sure thing! Patched dc8a908.

    点赞 评论 复制链接分享