5

I'm getting an error that looks like it's unable to resolve my import to my other module.

Running rollup -c I'm getting the following error

(!) Unresolved dependencies

https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency components/main/view (imported by src\index.js)

(!) Missing global variable name

Use output.globals to specify browser global variable names corresponding to external modules C:\Users\n88040\AppData\Roaming\npm\node_modules\rollup\dist\rollup.js (guessing 'View')

src/index.js

import View from 'components/main/view`;
View();

src/components/main/view.js

const View = () => console.log('foo');
export default View;
2
  • WOW, I feel dumb. Thank you. Please post that as the answer so I can accept and give you credit. Commented Mar 9, 2018 at 12:10
  • Don't need to feel dumb, you couldn't predict that you can't use based relatives path for rollup. Commented Sep 8, 2023 at 15:27

1 Answer 1

4

See https://rollupjs.org/guide/en#es-module-syntax

You have to import local dependencies with a leading period as otherwise it will be interpreted as an external dependency:

import View from './components/main/view';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.