vue+sass 下sass不能运行问题

2018-05-16 11:29:40 浏览数 (1)

好久没写博文了,今天抽空写一写,最近在用vue.js build 项目,今早想使用sass来编译css,可是安装好依赖包之后仍然显示一下错误:

代码语言:javascript复制
ERROR in ENOENT: no such file or directory, scandir '/Users/baidu/Documents/mydata/hfutoj/node_modules/.npminstall/node-sass/3.8.0/node-sass/vendor'
 @ ./~/vue-style-loader!./~/css-loader!./~/vue-loader/lib/style-rewriter.js!./~/.npminstall/sass-loader/4.0.0/sass-loader!./~/vue-loader/lib/selector.js?type=style&index=0!./src/components/footer.vue 4:14-273 13:2-17:4 14:20-279

  我vue component 里面是这样用的:

代码语言:javascript复制
<style lang="scss">
.footer {
  margin-top: 3em;
  padding-top: 2em;
  border-top: 1px solid #ccc;
  text-align: center;
  font-size: 1em;
  clear: both;
  height: 4em;}
</style>

 我心想不应该啊,我依赖包都安装了,需要的依赖包是:node-sass ,sass-loader,vue-style-loader,css-loader,分析了下,觉得是node-sass没安装好,所以我就卸载了node-sass,然后又重新安装(注意cnpm是需要使用npm安装的,这个好像是淘宝的镜像,比较快):

代码语言:javascript复制
npm remove node-sass
cnpm install node-sass

  package.json里是这样写的:

代码语言:javascript复制
{
  "name": "hfutoj",
  "version": "1.0.0",
  "description": "oj for hfut",
  "author": "hfuter",
  "private": true,
  "scripts": {
    "dev": "node build/dev-server.js",
    "build": "node build/build.js",
    "test": ""
  },
  "dependencies": {
    "vue": "^1.0.21",
    "babel-runtime": "^6.0.0",
    "semantic-ui": "*"
  },
  "devDependencies": {
    "babel-core": "^6.0.0",
    "babel-loader": "^6.0.0",
    "babel-plugin-transform-runtime": "^6.0.0",
    "babel-preset-es2015": "^6.0.0",
    "babel-preset-stage-2": "^6.0.0",
    "babel-register": "^6.0.0",
    "connect-history-api-fallback": "^1.1.0",
    "css-loader": "^0.23.0",
    "eventsource-polyfill": "^0.9.6",
    "express": "^4.13.3",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.8.4",
    "function-bind": "^1.0.2",
    "html-webpack-plugin": "^2.8.1",
    "http-proxy-middleware": "^0.12.0",
    "json-loader": "^0.5.4",
    "less": "^2.7.1",
    "less-loader": "^2.2.3",
    "node-sass": "^3.7.0",
    "ora": "^0.2.0",
    "sass-loader": "^4.0.0",
    "shelljs": "^0.6.0",
    "url-loader": "^0.5.7",
    "vue-hot-reload-api": "^1.2.0",
    "vue-html-loader": "^1.0.0",
    "vue-loader": "^8.3.0",
    "vue-style-loader": "^1.0.0",
    "webpack": "^1.12.2",
    "webpack-dev-middleware": "^1.4.0",
    "webpack-hot-middleware": "^2.6.0",
    "webpack-merge": "^0.8.3"
  }
}

  但是,仍然报错,为毛?我发现重装之后错误并没有变,仍然是.npminstall 下面的文件没被找到,所以.npminstall(这是个隐藏文件)下的文件并没有被卸载,所以我决定把整个node_modules删除了再重装(cnpm install),之后就好了,不过我把ndoe-sass的版本号由3.8.0换成了3.7.0

0 人点赞