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

Error: Cannot find module 'abortcontroller-polyfill/dist/cjs-ponyfill' #184

Closed
chrism opened this issue Dec 4, 2018 · 8 comments
Closed

Comments

@chrism
Copy link

chrism commented Dec 4, 2018

A similar issue was recently closed #115 but I do not understand how to resolve this issue in the case of linking a local dependency now with these recent updates.

For example, I currently need to use a branch of ember-cli-fastboot to fix an issue with the shoebox so I until the PR is merged I use this branch https://github.com/chrism/ember-cli-fastboot/tree/fix-shoebox which works when the remote URL is used in my package.json.

However, if I try to use this same branch locally, by using yarn link and yarn link "ember-cli-fastboot" in my test application then whereas this used to work I now get this error.

Error: Cannot find module 'abortcontroller-polyfill/dist/cjs-ponyfill'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.require (/Users/example/git/ember-cli-fastboot/node_modules/fastboot/src/ember-app.js:130:18)
    at Module.callback (/Users/example/git/example/tmp/broccoli_persistent_filterfastboot_manifest_rewrite__broccoli_asset_revfastboot_manifest_rewrite-output_path-nEn9sQXU.tmp/ember-fetch/fastboot-fetch-0afba248f49db81597281d5d1218fbf9.js:6:42)
    at Module.exports (/Users/example/git/example/tmp/broccoli_persistent_filterfastboot_manifest_rewrite__broccoli_asset_revfastboot_manifest_rewrite-output_path-nEn9sQXU.tmp/assets/vendor/loader/loader.js:106:1)
    at Module._reify (/Users/example/git/example/tmp/broccoli_persistent_filterfastboot_manifest_rewrite__broccoli_asset_revfastboot_manifest_rewrite-output_path-nEn9sQXU.tmp/assets/vendor/loader/loader.js:143:1)
    at Module.reify (/Users/example/git/example/tmp/broccoli_persistent_filterfastboot_manifest_rewrite__broccoli_asset_revfastboot_manifest_rewrite-output_path-nEn9sQXU.tmp/assets/vendor/loader/loader.js:130:1)
    at Module.exports (/Users/example/git/example/tmp/broccoli_persistent_filterfastboot_manifest_rewrite__broccoli_asset_revfastboot_manifest_rewrite-output_path-nEn9sQXU.tmp/assets/vendor/loader/loader.js:104:1)

This seems like a regression because it was working until recently (I needed it to work to develop the shoebox fix in the first place).

Have I missed something, or is this no longer possible?

@oscarni
Copy link

oscarni commented Dec 27, 2018

This happens to me when I resolve to fastboot 2.0.0 or above. Running Fastboot 1.2.1 works fine with ember-fetch 6.4.0. Maybe that could be the culprit?

@simonihmig
Copy link

I also stumbled into this. Even with the latest release.

This happens to me when I resolve to fastboot 2.0.0 or above. Running Fastboot 1.2.1 works fine with ember-fetch 6.4.0

Weird. It is just the opposite for me, I was able to fix it by forcing fastboot@2.0.1 on my app server. (not trying this locally, but on the real staging server)

I dug into this, and I think the use of existsSync is the culprit, which does not know anything about node's module resulution: https://github.com/ember-fastboot/fastboot/blob/v1.2.1/src/ember-app.js#L126

nodeModulesPath is something like .../dist/abortcontroller-polyfill/dist/cjs-ponyfill, and that file indeed does not exist physically, as the .js file type is missing here. So it tries to require not from within the dist path, and that fails.

In the latest version of fastboot the resolve package is used, which correctly understands that this is a valid module reference: https://github.com/ember-fastboot/fastboot/blob/master/src/ember-app.js#L139

@xg-wang
Copy link
Member

xg-wang commented Feb 2, 2019

I can confirm this happens on ember-cli-fastboot, not specific to your fork.
This happens when I do yarn link ember-cli-fastboot on a ember app.

I set a debugger at the line before node does require, then require.resolve('node-fetch') will error when link, but works well if not link.

It could be yarn link issue or ember-cli-fastboot issue which I don't know. fastboot@2.0.0 containing ember-fastboot/fastboot#200 is a good to have but it doesn't help with the link issue.

[I] ➜ ember --version --verbose
ember-cli: 3.6.1
http_parser: 2.8.0
node: 11.2.0
v8: 7.0.276.38-node.11
uv: 1.23.2
zlib: 1.2.11
ares: 1.15.0
modules: 67
nghttp2: 1.34.0
napi: 3
openssl: 1.1.0i
icu: 62.1
unicode: 11.0
cldr: 33.1
tz: 2018e
os: darwin x64

[I] ➜ yarn --version
1.12.3

@lucacorti
Copy link

I'm still getting this with ember-data@3.9.1 in fastboot.

Error: Cannot find module 'abortcontroller-polyfill/dist/cjs-ponyfill'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.require (node_modules/fastboot/src/ember-app.js:130:18)
    at a.callback (dist/ember-fetch/fetch-fastboot-5e5d008c8b65b0ac116f7635d0c6c6b9.js:1:24)
    at a.exports (dist/assets/vendor-4de0f4d6c6a261773e0e61365d28c09b.js:19:21)
    at a._reify (dist/assets/vendor-4de0f4d6c6a261773e0e61365d28c09b.js:22:35)
    at a.reify (dist/assets/vendor-4de0f4d6c6a261773e0e61365d28c09b.js:21:23)
    at a.exports (dist/assets/vendor-4de0f4d6c6a261773e0e61365d28c09b.js:18:84)

@xg-wang
Copy link
Member

xg-wang commented Aug 16, 2019

I believe this issue can be closed.

If there's something missing here please reopen or create another issue.

@xg-wang xg-wang closed this as completed Aug 16, 2019
@lucacorti
Copy link

@xg-wang works for me

@xg-wang xg-wang removed the needs response Original poster needs to respond label Aug 17, 2019
@devotox
Copy link

devotox commented Jan 26, 2020

I have found if you just install ember-fetch on the encapsulating server this works without the need to install all packages in the dist directory

@Brunoporto2702
Copy link

I believe this issue can be closed.

If there's something missing here please reopen or create another issue.

Do you know how to do that on a heroku server?

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

No branches or pull requests

8 participants