“npm run build:css”无法正常工作,而在运行脚本self时则可以

时间:2022-07-07 01:07:12

I am doing a program, I meet some question when I use the npm script with Mac system;
I have already install the node-sass globally, the package.json file is as follows: 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;

我正在做一个程序,当我在Mac系统中使用npm脚本时,我遇到了一些问题;我已经全局安装了node-sass,package.json文件如下:package.json当我运行“npm run build:css”时它不起作用,而系统告诉我的错误如下图所示:错误的描述,但我可以在终端成功运行命令node-sass ./src/scss/pages/index.scss ./static/css/index.css,如果我添加另一行像“创建”:“触摸太阳.js“to package.json,当我运行npm run create时效果很好;

I am confused, I will be grateful if someone can give some suggestion.

我很困惑,如果有人能提出一些建议,我将不胜感激。

2 个解决方案

#1


0  

It might be that the node-sass module that's installed locally in the working directory is missing dependencies, or is otherwise partially configured. Try running npm install to restore any missing dependencies.

可能是工作目录中本地安装的node-sass模块缺少依赖项,或者部分配置。尝试运行npm install以恢复任何缺少的依赖项。

The reason node-sass runs successfully in the terminal might be because it's running from a different (probably global) installation. Run which node-sass to find the location of the running executable..

node-sass在终端中成功运行的原因可能是因为它是从不同的(可能是全局的)安装运行的。运行哪个node-sass来查找正在运行的可执行文件的位置。

#2


0  

Why do you use node-sass? Here is my script, try this:

为什么使用node-sass?这是我的脚本,试试这个:

"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部分,当然,更改源和目​​标路径。

#1


0  

It might be that the node-sass module that's installed locally in the working directory is missing dependencies, or is otherwise partially configured. Try running npm install to restore any missing dependencies.

可能是工作目录中本地安装的node-sass模块缺少依赖项,或者部分配置。尝试运行npm install以恢复任何缺少的依赖项。

The reason node-sass runs successfully in the terminal might be because it's running from a different (probably global) installation. Run which node-sass to find the location of the running executable..

node-sass在终端中成功运行的原因可能是因为它是从不同的(可能是全局的)安装运行的。运行哪个node-sass来查找正在运行的可执行文件的位置。

#2


0  

Why do you use node-sass? Here is my script, try this:

为什么使用node-sass?这是我的脚本,试试这个:

"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部分,当然,更改源和目​​标路径。