运行时问题(npm run dev):
1,npm run dev报错:
This dependency was not found:
* !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-1d57e5ea","scoped":false,"hasInlineConfig":false}!stylus-loader?{"sourceMap":false}!../../node_modules/vue-loader/lib/selector?type=styles&index=0!./a.vue in ./src/components/a.vue
To install it, you can run: npm install --save !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-1d57e5ea","scoped":false,"hasInlineConfig":false}!stylus-loader?{"sourceMap":false}!../../node_modules/vue-loader/lib/selector?type=styles&index=0!./a.vue
解决方法:
npm install sass-loader --save;
npm install node-sass --save;
2,VUE 项目dependency was not found: * !!vue-style-loader!css-loader? 解决方案
用npm run dev 运行vue项目时,出现以下错误:
ERROR Failed to compile with 1 errors 11:17:27 This dependency was not found:
* !!vue-style-loader!css-loader?{"sourceMap":true}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-331f341c","scoped":true,"hasInlineConfig":false}!less-loader?{"sourceMap":true}!../../node_modules/vue-loader/lib/selector?type=styles&index=0!./Index.vue in ./src/components/Index.vue
To install it, you can run: npm install --save !!vue-style-loader!css-loader?{"sourceMap":true}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-331f341c","scoped":true,"hasInlineConfig":false}!less-loader?{"sourceMap":true}!../../node_modules/vue-loader/lib/selector?type=styles&index=0!./Index.vue
解决方法,看错误中列出了哪几个模块,都给装上:
npm install stylus-loader css-loader style-loader less-loader --save-dev
3,在vue中使用sass的配置的方法
- 安装sass的依赖包
npm install --save-dev sass-loader
//sass-loader依赖于node-sass
npm install --save-dev node-sass
- 在build文件夹下的webpack.base.conf.js的rules里面添加配置
{
test: /\.sass$/,
loaders: ['style', 'css', 'sass']
}
- 在APP.vue中修改style标签
<style lang="scss">
4,vue项目中,解决 node-sass安装出错
一般node-sass安装起来 本来就不稳定 保险一点就是全部重新安装
1)删除node_modules,不能在文件夹中删除,在终端执行下面命令
npm install rimraf -g
rimraf node_modules
2)重新安装依赖
npm install / cnpm install
3)安装node-sass
cnpm install node-sass
4)如果之前安装过node-sass
npm rm node-sass ---- 先移除包
cnpm install node-sass ----再安装
Ps:出现"Module build failed: Error: Cannot find module ‘lodash.clonedeep’ "
说明没有安装对,重新按正确命令安装。
5,运行时报错:Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value)(intermediate value)(...) is not a function
写了两个闭包子调用,但是第二个就老是出现下面错误,
解决方法:上一个闭包后加上;就行了
6,运行时报错Module build failed: Error: No PostCSS Config found in: /Users/abuuio/node_modules/vue-beauty/package/style at config.load.then (/Users/abuuio/Home/node_modules/postcss-load-config/src/index.js:55:15)
解决办法:新建一个文件叫 postcss.config.js 然后内容就写一行代码
module.exports = {}
按照它说的,在什么地方找不到这个文件就复制了同样的一份放到了相应的位置。这样bug就解决了。
7,Module build failed: Error: Cannot find module 'less'
解决方法:
npm install less
8,vue-cli创建项目报错npm ERR! Unexpected end of JSON input while parsing near '...",'
解决方法:
第一步:强制清除缓存 npm cache clean --force
第二步:(再安装) npm install
9,运行了一下cnpm run dev ,报错Cannot find module‘ XXX1’,使用cnpm install ‘XXX’ 在项目中插入该模块,然后再运行cnpm run dev,又接着报不能发现另一个模块Cannot find module‘ XXX2’,如此一直报错。。。
解决方案:删除项目目录下的 node_modules
目录,Linux下用root账户重新 npm install
或者 淘宝镜像 cnpm install
,Windows下用管理员权限运行terminal运行 npm install
或者 淘宝镜像 cnpm install