简体   繁体   English

运行 npm run compile:sass 返回错误:npm ERR: missing script: compile:sass

[英]Running npm run compile:sass returns error: npm ERR! missing script: compile:sass

The sass folders and files are in the correct place. sass 文件夹和文件在正确的位置。 What is wrong?怎么了?

I have the package.json which I created, with this code in there.我有我创建的 package.json,其中有这段代码。

{
  "name": "starter",
  "version": "1.0.0",
  "description": "starter file",
  "main": "index.js",
  "scripts": {
    "compile:sass": "node-sass sass/main.scss css/style.css -w"
  },
  "author": "Nez",
  "license": "ISC",
  "devDependencies": {
    "node-sass": "^4.12.0"
  }
}

As you can see the script is called compile sass when I try to run it it keeps giving the error npm ERR: missing script: compile:sass如您所见,当我尝试运行该脚本时,该脚本被称为 compile sass,它一直给出错误 npm ERR: missing script: compile:sass

I have the sass compiler installed already as a dev dependency我已经安装了 sass 编译器作为开发依赖项

I had this happen as well. 我也有这种情况。 The only way I could fix it was to move my files out of my dropbox folder on an external hard drive and move them to my main computers' hard drive. 我可以解决的唯一方法是将文件从外部硬盘驱动器上的保管箱文件夹中移出,然后将其移至主计算机的硬盘驱动器中。 I think it has something to do with Dropbox, but I'm not sure. 我认为这与Dropbox有关,但我不确定。

One of your sass files has a syntax error您的 sass 文件之一有语法错误

eg.例如。 file 1 has文件 1 有

  • background: %pink背景: %粉红色

the %pink value is undefined you should check your files if %pink * is implemented %pink值未定义,如果%pink * 被实现,你应该检查你的文件

我遇到了同样的问题并尝试了所有方法,直到我简单地将项目文件保存在我的代码编辑器中,然后突然它就起作用了。

Add this to your code all you need to do is add npx before your node将此添加到您的代码中,您需要做的就是在node之前添加npx

Ie npx node...npx node...

Then go to your terminal to that directory and run this command npm run compile:sass然后转到您的终端到该目录并运行此命令npm run compile:sass

Hope this works...because it worked for me will work for you too希望这有效……因为它对我有用,对你也有用

我想你应该检查你的文件路径

After 3 years. 3年后。 for me it's solved by rewriting the package:json "scripts" line :对我来说,它是通过重写 package:json “脚本”行解决的:

"compile:sass": "node-sass sass/main.scss css/style.css -w"
  1. Go to package.json Go 至 package.json
  2. add below lines添加以下行
"scripts": {
  "sass": "sass sass/main.scss css/style.css",
  "test": "echo \"Error: no test specified\" && exit 1"
      },
  1. For compilation use command: npm run sass编译使用命令: npm run sass

Note: I have used main.scss as source file name注意:我使用main.scss作为源文件名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用 npm 编译内联 sass? - Compile inline sass with npm? Angular NPM Run Prod:错误 npm ERR! 缺少脚本:prod - Angular NPM Run Prod: Error npm ERR! missing script: prod 尝试通过 npm 运行 node-sass 时出错 - Error when trying to run node-sass via npm node-sass 不使用 npm run css 命令编译 scss 文件 - node-sass does not compile scss file using npm run css command 无法在 Testcafe 错误消息中运行 percy 快照测试:npm ERR:缺少脚本:test:percy - Cannot run percy snap shot test in Testcafe error message: npm ERR! missing script: test:percy npm 错误:缺少脚本:在尝试运行我的 React 应用程序时启动 - npm ERR! missing script: start when trying to run my React app 当我运行 npm run dev 时如何知道编译哪个文件 - how to know which file compile when I run npm run dev npm run build 给出 npm ERR! 代码生命周期 - npm run build gives out npm ERR! code ELIFECYCLE 运行npm脚本时出现Typescript错误 - Getting Typescript error when I run an npm script 当我运行“npm install”时,我的终端上出现此错误消息“npm ERR。Linux 5.4.72-microsoft-standard-WSL2” - I have this error message "npm ERR! Linux 5.4.72-microsoft-standard-WSL2" on my terminal when I run "npm install"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM