简体   繁体   English

如何修复“npm ERR:缺少脚本:”

[英]how to fix "npm ERR! Missing script:"

I wrote the script "style", but for some reason does not want to execute it.我写了脚本“样式”,但出于某种原因不想执行它。 Using the npm run command, you can just execute the script "test": "echo "Error: no test specified" && exit 1" My package.json is below, as well as the full error message when I run a command:使用 npm 运行命令,您可以只执行脚本“test”:“echo “错误:未指定测试”&& exit 1” 我的 package.json 如下,以及我运行命令时的完整错误消息:

  {
  "name": "plants",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "style": "sass sass/style.scss sass/style.css",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

here I am trying to run a sktipt:在这里,我试图运行一个 sktipt:

npm run style
npm ERR! Missing script: "style"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\GRAFIK548\AppData\Local\npm-cache\_logs\2022-12-28T06_18_17_306Z-debug-0.log

and here I look at what scripts can be run:在这里我看看可以运行哪些脚本:

$ npm run
Lifecycle scripts included in plants@1.0.0:
  test
    echo "Error: no test specified" && exit 1

in general, I'm trying to connect sass via json一般来说,我正在尝试通过 json 连接 sass

thank you very much for any answer!!非常感谢您的任何回答!

NPM err missing script fix NPM 错误缺少脚本修复


I used to get this error a lot on my old computer.我曾经在我的旧电脑上经常遇到这个错误。 The easiest fix I found that worked was to just我发现最简单的解决方法就是

Try to use the absolute path of the file in your JSON.尝试使用你JSON中文件的绝对路径。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM