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

Error "Cannot find module 'vue-tsc/out/proxy'" #2227

Closed
prashantmirajkar opened this issue Dec 19, 2022 · 7 comments
Closed

Error "Cannot find module 'vue-tsc/out/proxy'" #2227

prashantmirajkar opened this issue Dec 19, 2022 · 7 comments
Labels

Comments

@prashantmirajkar
Copy link

In version 1.0.14 error "Cannot find module 'vue-tsc/out/proxy'" reported during build.
regards,

@splatEric
Copy link

I received the same error this morning. This was with latest versions of node and npm as well (which I updated just to check!!)

> vite build

error during build:
Error: Cannot find module 'vue-tsc/out/proxy'
$ npm -v
9.2.0
$ node -v
v18.12.1

@johnsoncodehk
Copy link
Member

Can you try delete node_modules and reinstall?

@splatEric
Copy link

sorry, I should've mentioned I did that as well. I also tried npm cache --clean --force in an act of desperation ;-)

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Dec 19, 2022

Please show following files of your project:

  • node_modules/.bin/tsc node_modules/.bin/vue-tsc
  • node_modules/vue-tsc/bin/vue-tsc.js
  • node_modules/vue-tsc/package.json

@splatEric
Copy link

$ more node_modules/.bin/tsc
#!/usr/bin/env node
require('../lib/tsc.js')
$ more node_modules/vue-tsc/bin/vue-tsc.js
#!/usr/bin/env node
const fs = require('fs');
const readFileSync = fs.readFileSync;
const tscPath = require.resolve('typescript/lib/tsc');
const proxyApiPath = require.resolve('../out/index');
const { state } = require('../out/shared');

fs.readFileSync = (...args) => {
        if (args[0] === tscPath) {
                let tsc = readFileSync(...args);

                // add *.vue files to allow extensions
                tryReplace(/supportedTSExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');
                tryReplace(/supportedJSExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');
                tryReplace(/allSupportedExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');

                // proxy startTracing, dumpTracingLegend
                tryReplace(/ = tracingEnabled\./g, ` = require(${JSON.stringify(proxyApiPath)}).loadTsLib().`);

                // proxy createProgram apis
                tryReplace(/function createProgram\(.+\) {/, s => s + ` return require(${JSON.stringify(proxyApiPath)}).createProgram(...argum
ents);`);

                return tsc;

                function tryReplace(search, replace) {
                        const before = tsc;
                        tsc = tsc.replace(search, replace);
                        const after = tsc;
                        if (after === before) {
                                throw 'Search string not found: ' + JSON.stringify(search.toString());
                        }
                }
        }
        return readFileSync(...args);
};

(function main() {
        try {
                require(tscPath);
        }
        catch (err) {
                if (err === 'hook') {
                        state.hook.worker.then(main);
                }
                else {
                        throw err;
                }
        }
})();
$ more node_modules/vue-tsc/package.json
{
        "name": "vue-tsc",
        "version": "1.0.14",
        "main": "out/index.js",
        "license": "MIT",
        "files": [
                "bin",
                "out/**/*.js",
                "out/**/*.d.ts"
        ],
        "repository": {
                "type": "git",
                "url": "https://github.com/johnsoncodehk/volar.git",
                "directory": "vue-language-tools/vue-tsc"
        },
        "bin": {
                "vue-tsc": "./bin/vue-tsc.js"
        },
        "dependencies": {
                "@volar/vue-language-core": "1.0.14",
                "@volar/vue-typescript": "1.0.14"
        },
        "peerDependencies": {
                "typescript": "*"
        },
        "gitHead": "ce4d48b37db784400e15fe08282edc836e24d4cd"
}

@pedrolamas
Copy link

Getting exactly the same issue right now! Here are my repro steps:

git clone https://github.com/fluidd-core/fluidd
cd fluidd
npm ci
npm i -D vue-tsc@latest
npm run build

Last step fails, but if I remove the npm i -D vue-tsc@latest it will work fine

@johnsoncodehk
Copy link
Member

Please pin 1.0.13 and wait for fi3ework/vite-plugin-checker#194.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants