Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

npm run test error

When trying to run: npm run test I got the following error:

PS D:\xampp81\htdocs\nuxtjs\NuxtTestUtilities_101> npm run test

test nuxt test

Using 2024-04-03 as fallback compatibility date. 12.43.04 Vitest "deps.inline" is deprecated. If you rely on vite-node directly, use "server.deps.inline" instead. Otherwise, consider using "deps.optimizer.ssr.include"

RUN v2.0.5 D:/xampp81/htdocs/nuxtjs/NuxtTestUtilities_101

Test Files no tests Tests no tests Start at 12:43:07 Duration 68ms (transform 0ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 0ms)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯Error: Failed to load url D:/xampp81/htdocs/nuxtjs/NuxtTestUtilities_101/node_modules/@nuxt/test-utils/dist/shared/runtime/global-setup (resolved id: D:/xampp81/htdocs/nuxtjs/NuxtTestUtilities_101/node_modules/@nuxt/test-utils/dist/shared/runtime/global-setup). Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-mCdpKltl.js:51599:17

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯Serialized Error: { code: 'ERR_LOAD_URL' }

Any clue why?

0 likes
1 reply
LaryAI's avatar
Level 58

The error message you're encountering suggests that the test runner is unable to find the file global-setup in the @nuxt/test-utils package. This could be due to several reasons, such as a misconfiguration in your test setup, missing dependencies, or an outdated package.

Here are some steps you can take to troubleshoot and resolve this issue:

  1. Check Dependencies: Ensure that all necessary dependencies are installed. Run the following command to install missing dependencies:

    npm install
    
  2. Update Dependencies: Sometimes, updating your dependencies can resolve issues related to missing files or deprecated configurations. Run the following command to update your packages:

    npm update
    
  3. Check nuxt.config.js: Ensure that your nuxt.config.js file is correctly configured for testing. You might need to add or update the test configuration. Here is an example configuration:

    export default {
      // Other configurations...
      test: {
        // Test-specific configurations
      }
    }
    
  4. Check package.json: Ensure that your package.json has the correct scripts and dependencies for running tests. Here is an example of what it might look like:

    {
      "scripts": {
        "test": "nuxt test"
      },
      "devDependencies": {
        "@nuxt/test-utils": "^2.0.5",
        "vitest": "^0.0.0" // Ensure this is the correct version
      }
    }
    
  5. Check File Existence: Verify that the file global-setup exists in the specified path. If it doesn't, you might need to reinstall the @nuxt/test-utils package:

    npm install @nuxt/test-utils
    
  6. Use Correct Configuration for Vitest: The error message mentions that Vitest "deps.inline" is deprecated. Update your vite.config.js to use the correct configuration:

    export default {
      test: {
        deps: {
          optimizer: {
            ssr: {
              include: ['@nuxt/test-utils']
            }
          }
        }
      }
    }
    
  7. Run Tests with Debugging: Sometimes running tests with additional debugging information can help identify the issue:

    DEBUG=* npm run test
    

By following these steps, you should be able to identify and resolve the issue causing the npm run test command to fail. If the problem persists, consider providing more details about your project setup and configuration for further assistance.

Please or to participate in this conversation.