如何修复“没有这样的文件或目录,lstat'scss /'”?

时间:2019-08-25 08:29:08

标签: css json npm sass visual-studio-code

我正在尝试在youtupe https://www.youtube.com/watch?v=gYzHS-n2gqU&t=900s上遵循一个简单的教程,他正尝试使用该脚本运行npm脚本“ sass”文件。
-当我执行命令 npm run sass 时,显示一条错误消息 错误:ENOENT:没有这样的文件或目录,lstat'scss /'

-我认为文件路径或文件权限存在问题,应该在哪里配置以查找正确的导演。
-这是folder structure
-当我将脚本替换为:

"scripts": {
    **"sass": "echo \"Error: no test specified\" "**
  },

工作正常。 ,但

"scripts": {
    "sass": "node-sass -w scss/ -o dist/css/ --recursive" 
  },

给我一​​个错误。  package.json:

 {
  "name": "abrahem_portfolio",
  "version": "1.0.0",
  "description": "PortFolio",
  "main": "index.js",
  "scripts": {
    **"sass": "node-sass -w scss/ -o dist/css/ --recursive"**

  },
  "author": "Abrahem Gh",
  "license": "ISC",
  "dependencies": {
    "node-sass": "^4.12.0"
  }
}

-作为指导,终端应显示以下内容:

  

abrahem_portfolio@1.0.0 sass C:\ Users \ Abrahim \ Abrahem_portfolio   node-sass -w scss / -o dist / css / --recursive

-但显示错误:

  

abrahem_portfolio@1.0.0 sass C:\ Users \ Abrahim \ Abrahem_portfolio   node-sass -w scss / -o dist / css / --recursive

fs.js:114
    throw err;
    ^

Error: ENOENT: no such file or directory, lstat 'scss/'
    at Object.lstatSync (fs.js:845:3)
    at Object.module.exports.parseDir (C:\Users\Abrahim\Abrahem_portfolio\node_modules\sass-graph\sass-graph.js:153:10)
    at Object.watcher.reset (C:\Users\Abrahim\Abrahem_portfolio\node_modules\node-sass\lib\watcher.js:17:21)
    at watch (C:\Users\Abrahim\Abrahem_portfolio\node_modules\node-sass\bin\node-sass:260:20)
    at run (C:\Users\Abrahim\Abrahem_portfolio\node_modules\node-sass\bin\node-sass:319:5)
    at Object.<anonymous> (C:\Users\Abrahim\Abrahem_portfolio\node_modules\node-sass\bin\node-sass:405:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! abrahem_portfolio@1.0.0 sass: `node-sass -w scss/ -o dist/css/ --recursive `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the abrahem_portfolio@1.0.0 sass script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Abrahim\AppData\Roaming\npm-cache\_logs\2019-08-25T07_38_42_251Z-debug.log

项目结构如下:https://i.stack.imgur.com/KG082.png

1 个答案:

答案 0 :(得分:0)

查看文件夹结构时,您会发现

"scripts": {
    "sass": "node-sass -w scss/ -o dist/css/ --recursive" 
  },

命令查找一个名为scss的文件夹,但是在您的项目结构中,您有一个名为sass的文件夹 因此,可以通过将sass文件夹重命名为scss来解决此错误。

以下解决方案可以解决该问题:

"scripts": {
    "sass": "node-sass -w sass/ -o dist/css/ --recursive" 
  },