question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot resolve dependency './../../../../../../../../../..' at '/'

See original GitHub issue

.babelrc

{
  "presets": [
    "env",
    "stage-0"
  ]
}

package.json

"devDependencies": {
  "babel-preset-env": "1.6.1",
  "babel-preset-stage-0": "6.24.1",
  "parcel-bundler": "1.4.1"
},
"scripts": {
  "start": "parcel -p 3000 ./app/index.html"
}

failed when app/index.html contains non # hrefs, like

<nav>
  <div class="grid-header nav-wrapper blue-grey lighten-1">
    <a href="/" class="brand-logo">&nbsp; Knockout.js</a>
    <a href="/" data-activates="mobile-menu" class="button-collapse">
      <i class="material-icons">menu</i>
    </a>
    <ul class="right hide-on-med-and-down">
      <li><a href="/">Home</a></li>
      <li><a href="/link1">Link 1</a></li>
      <li><a href="/link2">Link 2</a></li>
    </ul>
    <ul class="side-nav" id="mobile-menu">
      <li><a href="/">Home</a></li>
      <li><a href="/link1">Login</a></li>
      <li><a href="/link2">Logout</a></li>
    </ul>
  </div>
</nav>

error if index.html page contains <a href="/" ...>...</a>:

yarn start
yarn run v1.3.2
$ parcel -p 3000 ./app/index.html
Server running at http://localhost:3000 
🚨  /Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/app/index.html: Cannot resolve dependency './../../../../../../../../../..' at '/'
    at /Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
    at load (/Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
    at /Users/mak/Documents/code/test/js/knockout/knockout-examples/computed/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:166:21)

other info

yarn -v
1.3.2

node -v
v9.4.0

npm -v
5.6.0

uname -a
Darwin kostromin-mb.local 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov  9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64

note: build works fine if replace all href="/.." to href="#/..."


Regards, Maksim

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ayarin0x0commented, Jan 30, 2018

✨ It seems like parcel (1.5.0) has fixed this, here it is:

Virtualpaths, throw file not found error Details #487.



🚨 Here is what i think, maybe not correct. In parcel (1.4.1), HTMLAsset may mistake virtual path for a dependency,

https://github.com/parcel-bundler/parcel/blob/68258b1e53d086f173d2888d9fa367fcba891807/src/assets/HTMLAsset.js#L42-L54

but in fact, this ‘dependency’ is not ‘illegal’, then it console.error('Cannot resolve dependency')

So, if add this:

if (node.attrs) {
    for (let attr in node.attrs) {
      let elements = ATTRS[attr];
      if (elements && elements.includes(node.tag)) {
        let assetPath = this.addURLDependency(node.attrs[attr]);

        /* patch */
        if (node.tag === 'a' && node.attrs[attr].startsWith('/')) {
            continue
        }

        if (!isURL(assetPath)) {
          assetPath = urlJoin(this.options.publicURL, assetPath);
        }
        node.attrs[attr] = assetPath;
        this.isAstDirty = true;
      }
    }
}

a[href='/'] can temporary work fine.

Example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>#602</title>
</head>
<body>
    <div id="app">
        <a href="/"></a>
        <a href="/home"></a>
        <a href="/sidebar/foo"></a>
        <a href="assets/harusame.jpg" style="display: block; width: 100px; height: 100px; background-color: rgba(9, 19, 39, .5)">Link to asset</a>
    </div>
</body>
</html>

Before:

$ parcel irodorin.html
Server running at http://localhost:1234
⏳  Building...

Resolver line 17: resolved[0] E:\irodorin\irodorin\irodorin.html
⏳  Building irodorin.html...
Resolver line 17: resolved[0] E:\irodorin\irodorin\assets\harusame.jpg
⏳  Building harusame.jpg...
🚨  E:\irodorin\irodorin\irodorin.html: Cannot resolve dependency './..\..' at 'E:\'

...
...

After:

$ rm -rf .cache dist

$ parcel irodorin.html
Server running at http://localhost:1234
⏳  Building...

Resolver line 17: resolved[0] E:\irodorin\irodorin\irodorin.html
⏳  Building irodorin.html...
Resolver line 17: resolved[0] E:\irodorin\irodorin\assets\harusame.jpg
⏳  Building harusame.jpg...
✨  Built in 297ms.

in-browser

As for a[href='#'], isUrl has filtered it:

https://github.com/parcel-bundler/parcel/blob/68258b1e53d086f173d2888d9fa367fcba891807/src/assets/HTMLAsset.js#L47-L49

https://github.com/parcel-bundler/parcel/blob/68258b1e53d086f173d2888d9fa367fcba891807/src/utils/is-url.js#L3-L4

https://github.com/parcel-bundler/parcel/blob/68258b1e53d086f173d2888d9fa367fcba891807/src/utils/is-url.js#L8-L11

I’m sorry that my english isn’t good. 😭

0reactions
daggerokcommented, Jan 31, 2018

Hello again,

I can confirm that 1.5.1 fixed my issue.

Thank you!

PS: @marcuslindfeldt I will close this, but if you still have trouble, probably it would be better to create new issue.


Regards, Maksim

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot resolve dependency, but file exists #1986 - GitHub
i don't understand why pacel could not resolve a dependency. when i run parcel build index.html i get the error. /Users/tim/proj_/parcel-example ...
Read more >
reactjs - "Cannot resolve dependency" when importing local ...
I get Cannot resolve dependency 'f-app-hub' during build. However, VS Code shows no errors and is able to correctly identify and source ...
Read more >
Sync: Resolve dependencies > Cannot resolve [maven ...
1. Run java maven project (with maven dependencies from the private repository) within the IDEA. · 2. Maven configuration has password protected repositories ......
Read more >
Cannot Resolve Dependency to Assembly Error Occurs
Description. An error that the dependency to a Telerik assembly cannot be resolved occurs. Error Message. Cannot resolve dependency to assembly 'Telerik.
Read more >
'Cannot resolve dependency to assembly 'PostSharp, Version ...
In short, this is known issue with XAML compiler, where it tries to load assemblies referenced by your dependencies and generates the mentioned...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found