I just created a new Vue 3 project using create-vite-app tool:
npx create-vite-app vite-app-for-test
cd vite-app-for-test
npm install
The generated project structure is like this:
vite-app-for-test
|- /public
|- /src
|- /assets
|- /components
|- HelloWorld.vue
|- App.vue
|- main.js
|- index.css
|- index.html
|-package.json
Now I want to test out this feature: Instant Prototyping , on my project.
I've already installed Vue 3 and Vue CLI on my machine, both are the latest versions: #vue/cli 4.5.15, vue#3.2.21.
Then I followed the guide and installed #vue/cli-service-global globally:
npm install -g #vue/cli-service-global
I tried this first:
vue serve ./src/main.js
The server started, no errors were emitted, and the demo page shows correctly.
but if I apply this command on App.vue:
vue serve ./src/App.vue
Things are going wrong here. I got a warning in my terminal but the server started successfully though:
WARNING Compiled with 1 warning
warning in C:/Users/xxx/AppData/Roaming/npm/node_modules/#vue/cli-service-global/template/main.js
"export 'default' (imported as 'Vue') was not found in 'vue'
App running at:
- Local: http://localhost:8080/
- Network: unavailable
The browser display nothing when I opened http://localhost:8080/. And there are some errors logged by the console:
Uncaught TypeError: Cannot read properties of undefined (reading 'config')
at eval (main.js?6f7e:4)
at Module.C:\Users\xxx\AppData\Roaming\npm\node_modules\#vue\cli-service-global\template\main.js (chunk-vendors.js:470)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at Object.1 (app.js:1022)
at __webpack_require__ (app.js:849)
at checkDeferredModules (app.js:46)
at app.js:925
at app.js:928
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
There's a screenshot about the error in the generated code: see here, possibly useful.
What is going on? Is there any wrong when I run vue serve on a single .vue entry? And if it's a bug of Vue CLI, is there any alternative solution for instant prototyping?
Thanks in advance.
I'm meetting the same question when i try to test my single vue component with command "vue serve".No errors were emitted.I even noticed that instead of using the command "vue serve", it executed "vue-cli-service serve" instead.I get a blank page with just a div element with the 'id=app'.
Related
I have successfully created a Nuxt.js project with this configuration using the CLI:
Project name: test
Programming language: JavaScript
Package manager: Npm
UI framework: None
Nuxt.js modules: None
Linting tools: None
Testing framework: None
Rendering mode: Single Page App
Deployment target: Static (Static/JAMStack hosting)
Development tools: jsconfig.json
Version control system: Git
The developement server runs properly with npm run dev.
npm run build also runs without errors and tells me that:
Ready to run nuxt generate
But the execution of nuxt generate leads to the error Command 'nuxt' not found. This is strange because nuxt seems to be installed when I execute npm nuxt list.
I first reinstalled just nuxt and then all dependencies after deleting the node_modules/ folder, but the error remains the same. If I just run npm run start it tells me
Nuxt Fatal Error
Error: Output directory `dist/` does not exists, please use
`nuxt generate` before `nuxt start` for static target.
This is strange again because the .nuxt/dist/ folder exists.
Does anyone have an idea what is going wrong?
I have solved the problem. For me it works if I run npm run generate instead of nuxt generate.
I created a new project with the Vue CLI 3 (configured: babel, pwa, eslint, mocha). Running the test environment using npm run serve works just fine, but I can't build the project for production.
I installed the current version of the Vue CLI 3 and tried creating projects with different configurations. I get the following error message when building the project.
js/app.bb3f3c6e.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (/Users/.../untitled/node_modules/terser-webpack-plugin/dist/minify.js:176:23)
at module.exports (/Users/.../untitled/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
at handle (/Users/.../untitled/node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (/Users/.../untitled-adventure/node_modules/worker-farm/lib/child/index.js:51:3)
at process.emit (events.js:188:13)
at emit (internal/child_process.js:828:12)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
This is a known issue (vuejs/vue-cli#3407) with the terser 3.16 dependency.
The workaround is to install 3.14 for now:
npm i terser#3.14
Came back to an old Vue project. Try to bring it up on my local machine using 'vue serve' and I got the following error.
How do I specify a valid entry point for vue projects?
Command:
vue serve
Terminal Error:
"Failed to locate entry file in /Users/$username/Desktop/my-project.
"Valid entry file should be one of: main.js, index.js, App.vue or app.vue.
vue serve src/main.js
Need to add the file to start from after the serve command
npm run serve
need to type this command .
A better way of doing this would be to specify the path to the main.js file in the package.json file as follows:
"scripts": {
"dev": "vue serve src/main.js",
"prod": "vue build src/main.js"
}
And then simply run
npm run dev
for serving the project in the development environment and
npm run prod
for creating a production build under dist folder
I tried to create a new Vue app with Vuetify by using the command from Vuetify homepage.
Following is the command I used:
npm install #vue/cli -g
vue create my-app // all options are default settings when creating
cd my-app
vue add vuetify // all options are default settings when running
All commands above mentioned completed perfectly. However, after I launch the hot-reload developing environment by the following command.
npm run serve
An error would occur as the following standard output.
> my-app#0.1.0 serve /home/seanwu/my-app
> vue-cli-service serve
INFO Starting development server...
94% after seal
ERROR Failed to compile with 1 errors 3:05:24 PM
error in ./src/main.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
BrowserslistError: [BABEL] /home/seanwu/my-app/src/main.js: /home/seanwu/my-app contains both .browserslistrc and package.json with browsers (While processing: "/home/seanwu/my-app/node_modules/#vue/babel-preset-app/index.js$0")
at /home/seanwu/my-app/node_modules/browserslist/node.js:239:15
at eachParent (/home/seanwu/my-app/node_modules/browserslist/node.js:46:18)
at Object.findConfig (/home/seanwu/my-app/node_modules/browserslist/node.js:219:20)
at Function.loadConfig (/home/seanwu/my-app/node_modules/browserslist/node.js:150:37)
at browserslist (/home/seanwu/my-app/node_modules/browserslist/index.js:187:31)
at getTargets (/home/seanwu/my-app/node_modules/#babel/preset-env/lib/targets-parser.js:133:50)
at _default (/home/seanwu/my-app/node_modules/#babel/preset-env/lib/index.js:184:46)
at /home/seanwu/my-app/node_modules/#babel/helper-plugin-utils/lib/index.js:19:12
at loadDescriptor (/home/seanwu/my-app/node_modules/#babel/core/lib/config/full.js:163:14)
at cachedFunction (/home/seanwu/my-app/node_modules/#babel/core/lib/config/caching.js:42:19)
at loadPresetDescriptor (/home/seanwu/my-app/node_modules/#babel/core/lib/config/full.js:233:63)
at config.presets.map.descriptor (/home/seanwu/my-app/node_modules/#babel/core/lib/config/full.js:68:19)
at Array.map (<anonymous>)
at recurseDescriptors (/home/seanwu/my-app/node_modules/#babel/core/lib/config/full.js:66:38)
at recurseDescriptors (/home/seanwu/my-app/node_modules/#babel/core/lib/config/full.js:92:27)
at loadFullConfig (/home/seanwu/my-app/node_modules/#babel/core/lib/config/full.js:106:6)
# multi (webpack)-dev-server/client?http://192.168.1.76:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
I have no idea why this would happen as being new to front-end development and following every instruction from the Quick Start web page. Maybe there are some stupid mistakes I made to cause this error.
What Node/npm version are you using? I'd assume the official tutorial works/worked at some point. I'd use nvm to install different Node.js versions. That also changes the npm version. Then try npm install and npm start again.
Or you could delete .browserslistrc in /home/seanwu/my-app, so you don't have two conflicting files.
I am trying to publish a fork of an open source React component to npm and use load it in my webpack after a successful npm install of my published module.
The webpack is throwing a Module not found: Error: Cannot resolve 'file' or 'directory' ./Slider.jsx in /home1... error when loading.
The lib/index.js file that my rc-tools build created is:
1'use strict';
2
3 module.exports = require('./Slider.jsx');
while, the main fork of the repo has
1'use strict';
2
3 module.exports = require('./Slider');
as their created lib/index.js.
I am using the same build (rc-tools) tool as them and have nearly identical package.json. Why is my repo creating a different index.js and is this the cause of my webpack.config not loading?
Here is the link to the npm component: https://www.npmjs.com/package/meraki-slider
In my journey of learning about node and publishing, I simply forgot to remove the .jsx endings from my /src folder, which was causing my build to include them in my /lib folder and causing webpack to not compile. :P