简体   繁体   English

“ npm run build:css”无法正常运行,但是当我运行脚本自我时可以

[英]“npm run build:css ” can not work, while it is ok when I run the script self

I am doing a program, I meet some question when I use the npm script with Mac system; 我正在编写程序,在Mac系统上使用npm脚本时遇到了一些问题;
I have already install the node-sass globally, the package.json file is as follows: package.json 我已经全局安装了node-sass,package.json文件如下: package.json
it is not work when I run "npm run build:css",while the error the system tell me is as the follow picture: the err discription but I can run the commend node-sass ./src/scss/pages/index.scss ./static/css/index.css successfully in the terminal and if I add another line like "create":"touch sun.js" to package.json, it works well when I run npm run create ; 当我运行“ npm run build:css”时,它是行不通的,而系统告诉我的错误如下图: err说明, 但是我可以运行node-sass ./src/scss/pages/index.scss ./static/css/index.css赞扬的node-sass ./src/scss/pages/index.scss ./static/css/index.css在终端中成功运行,并且如果我在package.json中添加另一行,例如"create":"touch sun.js" ,则在运行npm run create时效果很好

I am confused, I will be grateful if someone can give some suggestion. 我很困惑,如果有人可以提出建议,我将不胜感激。

It might be that the node-sass module that's installed locally in the working directory is missing dependencies, or is otherwise partially configured. 可能是本地安装在工作目录中的node-sass模块缺少相关性,或者进行了部分配置。 Try running npm install to restore any missing dependencies. 尝试运行npm install恢复所有丢失的依赖项。

The reason node-sass runs successfully in the terminal might be because it's running from a different (probably global) installation. node-sass在终端中成功运行的原因可能是因为它是从其他(可能是全局)安装中运行的。 Run which node-sass to find the location of the running executable.. 运行which node-sass ,找到正在运行的可执行文件的位置。

Why do you use node-sass? 为什么使用node-sass? Here is my script, try this: 这是我的脚本,请尝试以下操作:

"scripts": {
    "sass": "sass --sourcemap=none --watch resources/assets/sass:public/assets/css"
  }

If you need the source map, just delete the --sourcemap=none part, and of course, change the source and destination path. 如果需要源映射,只需删除--sourcemap=none部分,然后更改源路径和目标路径即可。

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

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