dr-elephant window 编译问题-前端

编译脚本部分内容:
ember_assets=${project_root}/public/assets
ember_resources_dir=${ember_assets}/ember
ember_web_directory=${project_root}/web

# cd to the ember directory
cd ${ember_web_directory}

npm install
node_modules/bower/bin/bower install
node_modules/ember-cli/bin/ember build --prod
rm -r ${ember_resources_dir} 2> /dev/null
mkdir ${ember_resources_dir}
cp dist/assets/dr-elephant.css ${ember_resources_dir}/
cp dist/assets/dr-elephant.js ${ember_resources_dir}/
cp dist/assets/vendor.js ${ember_resources_dir}/
cp dist/assets/vendor.css ${ember_resources_dir}/
cp -r dist/fonts ${ember_assets}/
cd ${project_root}

降级node.js到7.10.1

  1. running npm install -g windows-build-tools from an elevated PowerShell (run as Administrator).

GitHub - felixrieseberg/windows-build-tools: :package: Install C++ Build Tools for Windows using npm

完成后 控制面板\程序\程序和功能会多出以下程序 

 C:\Users\youname\.windows-build-tools\vs_BuildTools.exe

bower配置代理上网 参考:Configuration · Bower

{
    "directory": "bower_components",
    "proxy": "http://127.0.0.1:10809",
    "https-proxy": "http://127.0.0.1:10809"
}

bower d3#4.2.6 CERT_HAS_EXPIRED Request to https://registry.bower.io/packages/d3 failed: certificate has expired

方法 2: 使用 HTTP 替代 HTTPS

bower install d3#4.2.6 --force

离线安装 node-sass win32-x64-51_binding.node

这些文件看起来是 node-sass 的预编译二进制文件 (binding.nodebinding.pdb) 对应不同的 Node.js 版本。在特定情况下,你可能需要手动安装这些二进制文件,以避免每次安装 node-sass 时都重新编译。以下是如何使用这些文件的详细步骤:

步骤 1:确定你的 Node.js 版本

首先,你需要确定你正在使用的 Node.js 版本。可以通过以下命令检查:

node -v 

例如,如果你得到的版本是 v14.x.x,那么你需要使用 win32-x64-83_binding.node 和相应的 .pdb 文件(假设 83 对应 Node.js v14.x.x,你可能需要根据实际情况查找正确的版本对照表)。

步骤 2:创建目录结构

在你的项目中,找到 node-sass 模块的安装位置。通常它会在 node_modules/node-sass 目录中。你需要在这个目录下创建 vendor 目录结构。

cd your_project_directory/node_modules/node-sass mkdir -p vendor/win32-x64-83 

步骤 3:复制文件

将预编译的二进制文件(binding.nodebinding.pdb)复制到 vendor 目录中。

# 假设你已经下载并解压了这些文件到某个临时目录 cp /path/to/win32-x64-83_binding.node vendor/win32-x64-83/binding.node cp /path/to/win32-x64-83_binding.pdb vendor/win32-x64-83/binding.pdb 

步骤 4:验证安装??

运行以下命令来验证 node-sass 是否可以正常工作:

npx node-sass --version 

如果一切配置正确,你应该能看到 node-sass 的版本信息,并且不再需要重新编译。

如何确定 对应版本

ChatGPT

要确定 node-sass 预编译二进制文件 (binding.node) 对应的 Node.js 版本,你可以查找 Node.js 的 ABI (Application Binary Interface) 版本。这些文件名中的数字通常表示 Node.js 的 ABI 版本。以下是一些常见的 Node.js 版本及其对应的 ABI 版本:

Node.js 版本ABI 版本
0.10.x11
0.12.x14
4.x46
5.x47
6.x48
7.x51
8.x57
9.x59
10.x64
11.x67
12.x72
13.x79
14.x83
15.x88
16.x93

确定 Node.js 版本的 ABI 版本

你可以通过运行以下命令来确定你当前的 Node.js 版本的 ABI 版本:

node -p process.versions.modules

The Broccoli Plugin: [Funnel] failed with: Error: ENOENT: no such file or directory, symlink 'D:\code\dr-elephant\web\tmp\funnel-input_base_path-5g6vKIJ6.tmp\adnan-wahab\pathgl\named-amd\main.js' -> 'D:\code\dr-elephant\web\tmp\funnel-output_path-pte71sJi.tmp\d3-plugins-dist\adnan-wahab\pathgl\named-amd\main.js'

at Object.fs.symlinkSync (fs.js:1034:18)

https://github.com/broccolijs/broccoli-funnel/issues/60  Broccoli Plugin: [Funnel] failed

https://github.com/broccolijs/broccoli-funnel/issues/53

Broccoli Merge Tree failing on Windows OS · Issue #42 · broccolijs/broccoli-merge-trees · GitHub

最终定位原因:目标的多级父目录不存在

解决办法:逐级创建目录

symlink-or-copy/index.js

symlinkWindows

if (options.canSymlinkFile) {
  var isExists = options.fs.existsSync(path.dirname(destPath));
  if (!isExists) {
    var parentDir = path.dirname(destPath);
    console.log("destPath " + destPath)
    console.log("parentDir " + parentDir)

// var WINDOWS_PREFIX = "\\\\?\\";
    const dirParts = parentDir.substring(4).split(path.sep);

    let currentPath = '';

    for (let part of dirParts) {
      currentPath = path.join(currentPath, part);
      currentPath= currentPath.replace("D:code","D:\\code")

      try {
        if (!fs.existsSync(currentPath)) {
          fs.mkdirSync(currentPath);
          console.log(`Created directory: ${currentPath}`);
        }
      } catch (err) {
        console.error(`Error creating directory: ${currentPath}`);
        console.error(`Error message: ${err.message}`);
        break;
      }
    }
   /*   options.fs.mkdirSync(parentDir.substring(4), {recursive: true}, (err) => {
        if (err) {
          console.error(`Error creating directory: ${err}`);
        } else {
          console.log('Directory created successfully');
        }
      });*/
  }
  options.fs.symlinkSync(srcPath, ((destPath)), 'file');
} 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hirolee88

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值