Closed williamstar closed 7 years ago
I got the same problem like this: ERROR Failed to compile with 1 errors This relative module was not found:
@williamstar how did u solve it ?
@xerosanyam In my case , I use the vscode and run the app by F5 at the dev-server or node dev-server.js because I want to debugg some detail. But you can run npm run dev to solve this problem, if you want to debugger code may be can use the chrome debugger symbol embed into code.
Was this solved? If so can someone post the solution?
请问有人解决了这个问题吗 才安装的vue cli利用其搭建项目npm run dev之后就报类似的错
Can someone please post the solution ?
I solved it by updating all the npm packages by:
npm i -g npm-check-updates
npm-check-updates -u
npm install
please commit your package.json before performing above operation
can someone solve this problem?
The solution I have suggested above doesnt work for you ?
@xerosanyam Doesnt work );
@xerosanyam The second input is invalid
@Tzrong 你的问题解决了吗
你会说英语吗?
@MrGrimod 你是说我?
是的,但谷歌翻译器确实可以中国。因此,不要在意。 对不起。
@MrGrimod 哈哈 没事 大家能指出问题所在就好
These relative modules were not found: 同样的问题大家是怎么解决的?
@Xuhengfeng 我也一直没找到方法,一直在等
This relative module was not found:
I got this error when I messed up the case of the filename. When I ran this on a build server running Linux (I use Mac for development) it failed because OS X is case-insensitive and Debian is case-sensitive.
I'm solved by next commands:
npm i -g npm-check-updates
npm-check-updates -u
npm install --no-bin-links
npm update
npm run dev
i have same problem, but I'm solved by next commands
npm install babel-loader
This may cause by project inited in an existing vue-cli project, I dig myself into a hole, lol. So I remove the project directory and re-create it, everything is working fine!.
If you haven't messed up with your webpack config, it is most likely that you have an issue with one of the npm packages. Clean/Verify the npm cache and then run the below commands, thats how I solved this.
npm i -g npm-check-updates
npm-check-updates -u
npm install
Check the path you are using.
I'm solved by re-install all modules :)
rm -rf node_modules
npm install
vue-*
modules in devDependencies
part of your package.json
file.npm i --upgrade --save-dev vue-style-loader
I have very similar problem. When I do "npm run serve" or "npm run build" I get this on console:
ERROR Failed to compile with 1 errors
This relative module was not found: *./app.vue in ./src/main.ts
None of solutions suggested above has no any effect. I alredy tried to checkout previous project commits, update global and local packages, clone and build project on other machines, delete and reinstall packages, delete package-lock.json, create new project via vue cli and add project files on new configuration - and nothing was changed.
Here is my main.ts
import Vue from 'vue';
import App from './app.vue';
import router from './router';
import store from './store';
Vue.config.productionTip = false;
new Vue({
router,
store,
render: (h) => h(App)
}).$mount('#app');
And here App.vue
<template>
<div id="app" class="container-fluid">
<header-component></header-component>
<main id="content" class="content row">
<transition name="fade">
<router-view/>
</transition>
</main>
<footer-component></footer-component>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import HeaderComponent from './components/header/header.component';
import FooterComponent from './components/footer/footer.component';
@Component({
components: {
HeaderComponent,
FooterComponent
}
})
export default class App extends Vue {}
</script>
<style lang="scss">
@import "../node_modules/bootstrap/dist/css/bootstrap.min.css";
@import "../node_modules/font-awesome/css/font-awesome.min.css";
@import "../node_modules/vue2-animate/dist/vue2-animate.min.css";
@import "./styles/main.scss";
</style>
Vue ^2.5.13, project created via vue cli ^3.0.0-beta.6 (also tried beta.15), using Typescript cli plugin ^3.0.0-beta.6
./app.vue in ./src/main.ts
shoudn’t app.vue be App.vue?
Thank you, @jkzing! Problem fixed.
I solve it by change filename form xxx.scss to xxx.css
此问题已解决 ,仔细看一看 是有好几个eslint插件没有引入进去。 对比vue-cli 和 你的package.json
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
this problem had been solved , the key is that we still need to import some eslint plugin , add these plugin in your package.json ,and npm install
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
when runing dev-server there throw these two Error
ERROR Failed to compile with 2 errors 10:53:28
These relative modules were not found:
- ./build/dev-client in multi ./build/dev-client ./src/main.js
- ./src/main.js in multi ./build/dev-client ./src/main.js
Listening at http://localhost:8080
node-version 6.8.0 window10 i don't modify the webpack default config, it can run the app sometime but mostly throw the error
I also got this error from not using the correct style attribute. Hope it helps someone!
(adding a note because search engines still brought me here in 2019)
I had the same kind of error after cloning a vuejs project on a new machine.
Turns out npm install
did not install development packages (maybe it assumed it was a production environment ; I'm using Linux Mint). I had to run an extra npm install --dev
to get them, and all "relative modules were not found" errors disappeared.
I'm still having this problem and none of the solutions above fixed it.
i am so tired of these little vue bugs that it spent my time on. Is this one fixed already by anyone?
i am so tired of these little vue bugs that it spent my time on. Is this one fixed already by anyone?
Most of the time, those aren't "little vue bugs", but rather issues with user environment. For exemple, having NODE_ENV
set to production
as an environment variable on the computer will cause npm to only install the dependencies
and not the devDependencies
.
There is also this upstream issue in friendly-errors-webpack-plugin which cause the error message to be incorrect in the case of the OP.
我的问题是:在main.js中有些模块没有引起来,即main.js中的部分import引入的有问题,供参考
Spent a whole day on this. In my case, my webpack config used postcss-loader
in the rules for css loading, but I did not install it via npm install --save-dev postcss-loader
.
The error message said nothing about "postcss-loader", the error was simply
* ./Hello.vue?vue&type=style&index=0&id=361a4bd2&scoped=true&lang=css& in ./src/components/Hello.vue
* ./App.vue?vue&type=style&index=0&lang=scss& in ./src/App.vue
Other two errors, namely
* ./assets/logo.png in ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=7ba5bd90&
* ./assets/dj.png in ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=7ba5bd90&
happened for the same general reason and mistake: I had declared (ok I did not but I copied a config which did) a module (and that's what was mentioned by the error, a module could not be found!), which I did not install, in this case: url-loader
installed it via npm install --save-dev url-loader
and the error went away.
Basically, you have to watch out that all modules which are used by your webpack config files are also installed in node_modules.
E.g. my webpack config which caused the above problems looked like this:
module: {
rules: [
...
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
see the url-loader for image files? (and of course postcss-loader for style files)
You can basically apply that rule for any module which is declared in the config but not appearing in package.json
. Install it, the error might go away.
import PieChart from '../components/charts/PieChart'
I had a mistake like that. I think it's a reference problem. I simply retyped import of reference with problems and it returned to work.
I used the VSCode and I used de auto-complete to write the import/reference.
I hope that this help you.
Same issue, when importing local JS file. Build server running Linux, I use mac for development.
I've tried to create the "src" directory with an empty "main.js" and I've no longer the error. :-)
I've run into one "relative modules not found" error from a different path (vuetify
project with nedb-core
). Trying with the suggested:
npm i -g npm-check-updates
npm-check-updates -u
npm install --no-bin-links
npm update
It found some outdated packages (core-js
, eslint-plugin-vue
, stylus-loader
etc) and as a result I now have 4 extra "relative modules not found" errors related to core-js
. At this point I have no clue whether it is a webpack issue or what else.
All in all, it feels like a quite fragile development environment.
remove 'import func from './vue-temp/vue-editor-bridge' this statement. vscode auto will import this statement when enter 'tab' key before declare func
I'm solved by re-install all modules :)
rm -rf node_modules npm install
Cheer!!!!!!! This actually worked for me!!
I was having a similar issue where I created a component called "Home.vue" and the import statement in the router.js page "import Home from './components/Home.vue';" wasn't working and kept returning me
This relative module was not found:
* ./components/Home.vue in ./src/router.js
Why is this? I did not change any dev setting or env variables.
In my case I wanted to include ../../
beyond symlinks. I used a better approach to include my local component.
DELETE everything inside these folders:
it worked for me
Had a line I did not enter in my file: import func from '../../vue-temp/vue-editor-bridge';
. @bobohuochai suggests VS Code, and that could be. But simply removing it removed the error.
when runing dev-server there throw these two Error
ERROR Failed to compile with 2 errors 10:53:28
These relative modules were not found:
node-version 6.8.0 window10 i don't modify the webpack default config, it can run the app sometime but mostly throw the error