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

Bug: Failed to resolve entry for package "vue-router". #225

Closed
V35CH opened this issue Jul 6, 2022 · 1 comment
Closed

Bug: Failed to resolve entry for package "vue-router". #225

V35CH opened this issue Jul 6, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@V35CH
Copy link

V35CH commented Jul 6, 2022

When I run "vite" to create my project I get these errors. What do I do wrong? Does any one know where my error is?

Info

Tool Version
Plugin v1.6.0
Vue v3.2.13
Vite v2.9.13
Node v8.13.2
OS mac

Input

// main.js

import { createApp } from "vue";
import App from "./App.vue";
import { createGtm } from "@gtm-support/vue-gtm";

import "./css/index.css";

const app = createApp(App);

app.use(
  createGtm({
    id: "GTM-xxxxxx", // Your GTM single container ID, array of container ids ['GTM-xxxxxx', 'GTM-yyyyyy'] or array of objects [{id: 'GTM-xxxxxx', queryParams: { gtm_auth: 'abc123', gtm_preview: 'env-4', gtm_cookies_win: 'x'}}, {id: 'GTM-yyyyyy', queryParams: {gtm_auth: 'abc234', gtm_preview: 'env-5', gtm_cookies_win: 'x'}}], // Your GTM single container ID or array of container ids ['GTM-xxxxxx', 'GTM-yyyyyy']
    queryParams: {
      // Add URL query string when loading gtm.js with GTM ID (required when using custom environments)
      gtm_auth: "AB7cDEf3GHIjkl-MnOP8qr",
      gtm_preview: "env-4",
      gtm_cookies_win: "x",
    },
    defer: false, // Script can be set to `defer` to speed up page load at the cost of less accurate results (in case visitor leaves before script is loaded, which is unlikely but possible). Defaults to false, so the script is loaded `async` by default
    compatibility: false, // Will add `async` and `defer` to the script tag to not block requests for old browsers that do not support `async`
    nonce: "2726c7f26c", // Will add `nonce` to the script tag
    enabled: true, // defaults to true. Plugin can be disabled by setting this to false for Ex: enabled: !!GDPR_Cookie (optional)
    debug: true, // Whether or not display console logs debugs (optional)
    loadScript: true, // Whether or not to load the GTM Script (Helpful if you are including GTM manually, but need the dataLayer functionality in your components) (optional)
    // vueRouter: router, // Pass the router instance to automatically sync with router (optional)
    ignoredViews: ["homepage"], // Don't trigger events for specified router names (optional)
    trackOnNextTick: false, // Whether or not call trackView in Vue.nextTick
  })
);

app.mount("#app");

Output or Error

✘ [ERROR] [plugin vite:dep-pre-bundle] Failed to resolve entry for package "vue-router". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "vue-router" package

    node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:40945:10:
      40945 │     throw new Error(`Failed to resolve entry for package "${id}". ` +
            ╵           ^

    at packageEntryFailure (/Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:40945:11)
    at resolvePackageEntry (/Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:40941:9)
    at tryNodeResolve (/Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:40748:20)
    at Context.resolveId (/Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:40556:28)
    at Object.resolveId (/Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:39229:55)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:61552:27
    at async /Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:38746:34
    at async callback (/Users/ob/Data/node_modules/esbuild/lib/main.js:921:28)
    at async handleRequest (/Users/ob/Data/node_modules/esbuild/lib/main.js:701:30)

  This error came from the "onResolve" callback registered here:

    node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:38725:18:
      38725 │             build.onResolve({ filter: /^[\w@][^:]/ }, async ({ path: id, importer, kind }) => {
            ╵                   ~~~~~~~~~

    at setup (/Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:38725:19)
    at handlePlugins (/Users/ob/Data/node_modules/esbuild/lib/main.js:843:23)
    at Object.buildOrServe (/Users/ob/Data/node_modules/esbuild/lib/main.js:1137:7)
    at /Users/ob/Data/node_modules/esbuild/lib/main.js:2085:17
    at new Promise (<anonymous>)
    at Object.build (/Users/ob/Data/node_modules/esbuild/lib/main.js:2084:14)
    at Object.build (/Users/ob/Data/node_modules/esbuild/lib/main.js:1931:51)
    at runOptimizeDeps (/Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:39969:34)
    at async runOptimizer (/Users/ob/Data/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:50498:38)

  The plugin "vite:dep-pre-bundle" was triggered by this import

    node_modules/@gtm-support/vue-gtm/dist/index.js:116:93:
      116 │                     return [4 /*yield*/, Promise.resolve().then(function () { return require('vue-router'); })];
          ╵                                                                                              ~~~~~~~~~~~~

3:08:40 PM [vite] error while updating dependencies:
Error: Build failed with 1 error:
node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:40945:10: ERROR: [plugin: vite:dep-pre-bundle] Failed to resolve entry for package "vue-router". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "vue-router" package
    at failureErrorWithLog (/Users/ob/Data/node_modules/esbuild/lib/main.js:1605:15)
    at /Users/ob/Data/node_modules/esbuild/lib/main.js:1251:28
    at runOnEndCallbacks (/Users/ob/Data/node_modules/esbuild/lib/main.js:1034:63)
    at buildResponseToResult (/Users/ob/Data/node_modules/esbuild/lib/main.js:1249:7)
    at /Users/ob/Data/node_modules/esbuild/lib/main.js:1358:14
    at /Users/ob/Data/node_modules/esbuild/lib/main.js:666:9
    at handleIncomingPacket (/Users/ob/Data/node_modules/esbuild/lib/main.js:763:9)
    at Socket.readFromStdout (/Users/ob/Data/node_modules/esbuild/lib/main.js:632:7)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:315:12)
Vite Error, /node_modules/.vite/deps/@gtm-support_vue-gtm.js?v=06a117ea optimized info should be defined
Vite Error, /node_modules/.vite/deps/@gtm-support_vue-gtm.js?v=06a117ea optimized info should be defined (x2)

Tanks
Oliver

@V35CH
Copy link
Author

V35CH commented Jul 7, 2022

I explicitly installed vue router 4.0.16 in my project. That solved the problem. Thanks to #226

@V35CH V35CH closed this as completed Jul 7, 2022
@Shinigami92 Shinigami92 added the duplicate This issue or pull request already exists label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants