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

Did not get error that my relative path was not starting with node_modules #284

Open
melvinroest opened this issue Oct 12, 2019 · 6 comments

Comments

@melvinroest
Copy link

melvinroest commented Oct 12, 2019

My path was vendor/edited/bugout/index.js. It took me a long time to figure out what went wrong, until I read the source of this library since I was guessing it reads out the node_modules folder. I did not get the error: The "cjs" transform works only with NPM packages.
You tried to use it with "${relativePath}". Make sure your imported file path
begins with "node_modules/".

This is my full output of the command ember serve --port 4444

Could not start watchman
Visit https://ember-cli.com/user-guide/#watchman for more info.
Cannot find module '.js' from '/Users/username/path_to_app'


Stack Trace and Error Report: /var/folders/_4/xkxbjb2x1173s0mpwmxcqkkh0000gn/T/error.dump.e7c384ff0fbccc21ee4b04b0ced69e44.log

The stack trace and error report also didn't show it.

@nathankellenicki
Copy link

We also ran into this issue. My guess is that the throw is captured higher up and a more generic "Cannot find module" error is spat out.

The bigger issue is though, that we are doing the same as you - vendoring our dependencies inside a vendor/ directory, which this addon explicitly can't support.

@GavinJoyce
Copy link

GavinJoyce commented Dec 6, 2019

The "cjs" transform works only with NPM packages.
You tried to use it with "${relativePath}". Make sure your imported file path
begins with "node_modules/".

Is there a technical reason why the file being transformed needs to be in node_modules? I have a build time AST transform (in common js), which I also want to use at runtime in an ember app (a code playground type app), and I'm struggling to find a way of reusing this file other than extracting to a separate package

@rwjblue
Copy link
Owner

rwjblue commented Dec 6, 2019

@GavinJoyce - Largely due to the way we cache. It would be possible to remove the requirement that it start with node_modules, but would take a bit more care to get the caching bits right.

@allinne
Copy link

allinne commented Feb 25, 2020

Are there any news? I ran into this issue also.

Copy link
Owner

rwjblue commented May 7, 2020

Nope, doesn't seem like anyone has had a chance to dig into what is going on.

@noyesa
Copy link

noyesa commented Sep 9, 2021

I just ran into this as well. I wasn't aware this doesn't support non-NPM modules and ran into the problem with the slice on the file path here:

let fullPath = resolveSync(relativePath.slice(NODE_MODULES.length), {

It seems calculateCacheKey gets called before the node_modules validation happens in processFile.

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

6 participants