简体   繁体   English

带有SASS的Angular-CLI离线

[英]Angular-CLI with SASS offline

I am trying to compile an Angular project with SASS using Angular-CLI. 我正在尝试使用Angular-CLI用SASS编译Angular项目。 My server is behind a firewall, and cannot pull files from the Internet. 我的服务器在防火墙后面,无法从Internet提取文件。 It can, however, connect to an npm repo that has pre-approved packages. 但是,它可以连接到具有预先批准的软件包的npm存储库。 I have downloaded and copied win32-x64-48_binding.node to a local folder and set the SASS-BINARY-PATH environment variable to point to this file. 我已经下载了win32-x64-48_binding.node并将其复制到本地文件夹,并将SASS-BINARY-PATH环境变量设置为指向该文件。

I have created the project using the command: 我已经使用以下命令创建了项目:

ng new myproject --style=sass

Then I restored the packages with: 然后,我使用以下方法还原了软件包:

npm install --sass-binary-path=d:\path\to\win32-x64-48_binding.node

So far, so good. 到现在为止还挺好。 Finally when I run: 最后,当我运行时:

ng build

I get the error: 我得到错误:

Error in ./src/app/app.component.sass Module build failed: Error: ENOENT: no such file or directory, scandir 'd:\\Projects\\Angular\\myproject\\node_modules\\node-sass\\vendor' ./src/app/app.component.sass中的错误模块构建失败:错误:ENOENT:没有这样的文件或目录,scandir'd:\\ Projects \\ Angular \\ myproject \\ node_modules \\ node-sass \\ vendor'

... ...

I don't have a vendor directory because I installed the binding.node using a different binary path. 我没有供应商目录,因为我使用其他二进制路径安装了binding.node。 What do I need to do to get the ng build to work with this offline/SASS scenario? 我需要怎么做才能使ng构建与此离线/ SASS场景一起使用?

Add the SASS_BINARY_PATH variable to your System Environment Variables. SASS_BINARY_PATH变量添加到您的系统环境变量中。 This is because binding parameters for node-sass only work during npm install . 这是因为node-sass的绑定参数仅在npm install期间起作用。 They won't be used during compilation; 它们不会在编译期间使用; such as, ng build or ng serve 例如, ng buildng serve

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

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