Vue Cli Change Entry File (main.ts to main.js)

Feb 8, 2020

I setup a vue project via cli and selected TypeScript as the default language, thus main.ts is created as the default entry point.

I wanted to switch main.ts to main.js to use JavaScript instead of TypeScript.

Running npm run serve report the following error

INFO  Starting development server...
Starting type checking service...
Using 1 worker with 2048MB memory limit
98% after emitting CopyPlugin

 ERROR  Failed to compile with 2 errors                               3:51:27 PM

This relative module was not found:

* ./src/main.ts in multi (webpack)-dev-server/client?http://10.0.2.15:8081/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts, multi (webpack)-dev-server/client?http://localhost (webpack)/hot/dev-server.js (webpack)-dev-server/client?http://10.0.2.15:8081/sockjs-node ./src/main.ts
Type checking in progress...
No type errors found

It seems like npm run serve is still referring to main.ts.

To solve this issue, edit /vue.config.js (create the file at root project directory if it does not exist).

module.exports = {  pages: {    index: {      entry: 'src/main.js'    }  }}

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.