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

VS Code: The Svelte server crashed 5 times. Cannot find module @rollup/rollup-win32-x64-msvc #11679

Closed
8483 opened this issue May 18, 2024 · 8 comments
Labels
awaiting submitter needs a reproduction, or clarification

Comments

@8483
Copy link

8483 commented May 18, 2024

Describe the bug

Happens when saving and Prettier tries to format the code.

Reproduction

No reproduction.

Logs

Error: Cannot find module @rollup/rollup-win32-x64-msvc. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
    at requireWithFriendlyError (c:\user\dev\lab\posto\app\node_modules\rollup\dist\native.js:59:9)
    at Object.<anonymous> (c:\user\dev\lab\posto\app\node_modules\rollup\dist\native.js:68:76)
    ... 2 lines matching cause stack trace ...
    at Module.load (node:internal/modules/cjs/loader:1126:32)
    at Module._load (node:internal/modules/cjs/loader:967:12)
    at c._load (node:electron/js2c/node_init:2:13672)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:171:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
  [cause]: Error: Cannot find module '@rollup/rollup-win32-x64-msvc'
  Require stack:
  - c:\user\dev\lab\posto\app\node_modules\rollup\dist\native.js
      at Module._resolveFilename (node:internal/modules/cjs/loader:1084:15)
      at Module._load (node:internal/modules/cjs/loader:929:27)
      at c._load (node:electron/js2c/node_init:2:13672)
      at Module.require (node:internal/modules/cjs/loader:1150:19)
      at require (node:internal/modules/cjs/helpers:119:18)
      at requireWithFriendlyError (c:\user\dev\lab\posto\app\node_modules\rollup\dist\native.js:41:10)
      at Object.<anonymous> (c:\user\dev\lab\posto\app\node_modules\rollup\dist\native.js:68:76)
      at Module._compile (node:internal/modules/cjs/loader:1271:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1326:10)
      at Module.load (node:internal/modules/cjs/loader:1126:32) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
      'c:\\user\\dev\\lab\\posto\\app\\node_modules\\rollup\\dist\\native.js'
    ]
  }
}

Node.js v18.18.2
[Error - 3:22:18 AM] The Svelte server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

System Info

N/A

Severity

annoyance

@Conduitry
Copy link
Member

Did you look into whether you're experiencing the npm bug mentioned in the error message?

Otherwise, we'll need a reproduction. If this is due to Rollup not being able to find one of its dependencies, that would be unrelated to Svelte.

@Conduitry Conduitry added the awaiting submitter needs a reproduction, or clarification label May 18, 2024
@dummdidumm
Copy link
Member

Sounds related to #11667, maybe try the suggestions in that linked issue

@jasonlyu123
Copy link
Member

Another similar error sveltejs/language-tools#2341. This error is likely because your node.js installation and VSCode are running on different architectures.

@8483
Copy link
Author

8483 commented May 19, 2024

@Conduitry

Did you look into whether you're experiencing the npm bug mentioned in the error message?

Yes, I explored it. I am posting here because it lead nowhere.

If this is due to Rollup not being able to find one of its dependencies, that would be unrelated to Svelte.

Apologies for posting in the wrong place.


@dummdidumm @jasonlyu123

Sounds related to #11667, maybe try the suggestions in that linked issue
Another similar error sveltejs/language-tools#2341. This error is likely because your node.js installation and VSCode are running on different architectures.

I tried all of these before posting here. I should have mentioned it.

My nodejs runs in x64, checked with this command.

node -p "process.arch"

Also, my VS Code is 64-bit.

The solutions you linked address the 32-bit vs 64-bit mismatch, which is not the case for me.

What's weirder is that everything was running fine before.

All the problems started when I switched from Svelte 3 to the latest of Svelte 4. I deleted node_modules and package-lock.json before updating to 4.


Here are my files:

package.json

{
    "name": "app",
    "version": "0.0.0",
    "type": "module",
    "scripts": {
        "dev": "vite",
        "build": "vite build",
        "preview": "vite preview"
    },
    "devDependencies": {
        "@sveltejs/vite-plugin-svelte": "^3.1.0",
        "page": "^1.11.6",
        "svelte": "^4.2.16",
        "tabulator-tables": "^6.2.1",
        "vite": "^5.2.11"
    }
}

svelte.config.js

import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'

export default {
  // Consult https://svelte.dev/docs#compile-time-svelte-preprocess
  // for more information about preprocessors
  preprocess: vitePreprocess(),
}

vite.config.js

import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [svelte()],
    server: {
        proxy: {
            "/public": "http://localhost:3000",
            "/auth": "http://localhost:3000",
            "/api": "http://localhost:3000",
        },
    },
    esbuild: {
        drop: ["console", "debugger"],
    },
});

jsonconfig.json

{
    "compilerOptions": {
        "moduleResolution": "Node",
        "target": "ESNext",
        "module": "ESNext",
        /**
         * svelte-preprocess cannot figure out whether you have
         * a value or a type, so tell TypeScript to enforce using
         * `import type` instead of `import` for Types.
         */
        "importsNotUsedAsValues": "error",
        "isolatedModules": true,
        "resolveJsonModule": true,
        /**
         * To have warnings / errors of the Svelte compiler at the
         * correct position, enable source maps by default.
         */
        "sourceMap": true,
        "esModuleInterop": true,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true,
        /**
         * Typecheck JS in `.svelte` and `.js` files by default.
         * Disable this if you'd like to use dynamic types.
         */
        "checkJs": false // true
    },
    /**
     * Use global.d.ts instead of compilerOptions.types
     * to avoid limiting type declarations.
     */
    "include": ["src/**/*.js", "src/**/*.svelte"] // "src/**/*.d.ts",
}

@8483
Copy link
Author

8483 commented May 19, 2024

UPDATE

Running this command:

npm install --save-dev "@rollup/rollup-win32-x64-msvc"

Gave me this error:

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @rollup/rollup-win32-x64-msvc@4.17.2: wanted {"os":"win32","cpu":"x64"} (curre│
nt: {"os":"linux","cpu":"x64"})  
npm ERR! notsup Valid os:   win32  
npm ERR! notsup Actual os:  linux 
npm ERR! notsup Valid cpu:  x64
npm ERR! notsup Actual cpu: x64 

npm ERR! A complete log of this run can be found in: /home/ivan/.npm/_logs/2024-05-19T10_09_43_996Z-debug-0.log

I guess this must be the problem? But how did it work beforehand?

I am using WSL on Windows.

@jasonlyu123
Copy link
Member

Rollup only added the native module recently. So it is most likely because you updated to the latest version of rollup as well.

If you're using WSL, you should use the WSL extension. That should make non-ui stuff to run on Linux a

@jasonlyu123
Copy link
Member

Rollup only added the native module recently. So it is most likely because you updated to the latest version of rollup as well.

If you're using WSL, you should use the WSL extension and open the workspace in WSL. That should make non-ui stuff run on Linux and that should also solve the problem.

@8483
Copy link
Author

8483 commented May 19, 2024

@jasonlyu123 Interesting...

I navigated through the WSL terminal to the directory, and opened it with:

code .

This prompted me to reinstall all the VS Code extensions for Windows, for Linux as well, specifically the Svelte for VS Code extension.

I don't know how, but the whole VS Code seems to have switched to a WSL version as new features suddenly appeared...

I no longer get the error and Prettier works as expected.

Thanks for the help!

@8483 8483 closed this as completed May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter needs a reproduction, or clarification
Projects
None yet
Development

No branches or pull requests

4 participants