【问题标题】:Yarn - Node Sass does not yet support my current environmentYarn - Node Sass 还不支持我当前的环境
【发布时间】:2019-09-22 05:50:51
【问题描述】:

我正在使用 Sage WordPress 入门主题 - https://github.com/roots/sage

从今天开始运行 yarn build (webpack --progress --config /webpack.config.js) 出现这个错误:Module build failed: ModuleBuildError: Module build failed: Error: Node Sass does not yet support您当前的环境:OS X 64-bit with Unsupported runtime (72) 有关支持哪些环境的更多信息,请参阅: https://github.com/sass/node-sass/releases/tag/v4.8.3

我也尝试使用 brew 卸载并重新安装 node、npm 和 yarn,但没有任何改变。

如果我运行 npm install 这是错误

../src/create_string.cpp:17:25: error: no matching constructor for initialization of 'v8::String::Utf8Value'
  v8::String::Utf8Value string(value);
                        ^      ~~~~~
/Users/MYPC/.node-gyp/12.1.0/include/node/v8.h:3002:5: note: candidate constructor not viable: no known conversion from 'v8::Local<v8::Value>' to 'const v8::String::Utf8Value'
      for 1st argument
    Utf8Value(const Utf8Value&) = delete;
    ^
/Users/MYPC/.node-gyp/12.1.0/include/node/v8.h:2995:5: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
    Utf8Value(Isolate* isolate, Local<v8::Value> obj);
    ^
1 error generated.
make: *** [Release/obj.target/binding/src/create_string.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/MYPC/mysiteteam/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:196:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:256:12)
gyp ERR! System Darwin 18.5.0
gyp ERR! command "/usr/local/Cellar/node/12.1.0/bin/node" "/Users/MYPC/mysiteteam/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/MYPC/mysiteteam/node_modules/node-sass
gyp ERR! node -v v12.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN stylelint-webpack-plugin@0.10.5 requires a peer of webpack@^1.13.2 || ^2.7.0 || ^3.11.0 || ^4.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! **node-sass@4.9.4 postinstall: `node scripts/build.js`**
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.9.4 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/MYPC/.npm/_logs/2019-05-03T16_22_30_277Z-debug.log

所以我试图用这个命令行重建 node-sass npm rebuild node-sass --force 但错误是一样的!!! p>

更多信息

MacOs Mojave 版本 10.14.4

2.7 GHz 英特尔酷睿 i7

npm -v

6.9.0

节点-v

v12.1.0

纱线-v

1.15.2

package.json 依赖项

  "devDependencies": {
    "autoprefixer": "~8.2.0",
    "browser-sync": "~2.24.7",
    "browsersync-webpack-plugin": "^0.6.0",
    "bs-html-injector": "~3.0",
    "buble-loader": "^0.4.1",
    "cache-loader": "~1.2.5",
    "clean-webpack-plugin": "^0.1.18",
    "copy-globs-webpack-plugin": "^0.2.0",
    "css-loader": "^0.28.9",
    "cssnano": "~4.0.5",
    "eslint": "~4.19.1",
    "eslint-loader": "~1.9",
    "eslint-plugin-import": "~2.14.0",
    "extract-text-webpack-plugin": "~3.0.2",
    "file-loader": "^1.1.6",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "imagemin-mozjpeg": "~7.0.0",
    "imagemin-webpack-plugin": "~2.2.0",
    "import-glob": "~1.5",
    "node-sass": "~4.9.4",
    "postcss-loader": "~2.1.0",
    "postcss-safe-parser": "~3.0",
    "resolve-url-loader": "~2.3.1",
    "rimraf": "~2.6",
    "sass-loader": "~6.0",
    "style-loader": "^0.22.1",
    "stylelint": "^8.4.0",
    "stylelint-config-standard": "~18.2.0",
    "stylelint-webpack-plugin": "^0.10.5",
    "uglifyjs-webpack-plugin": "^1.3.0",
    "url-loader": "^0.6.2",
    "webpack": "~3.10.0",
    "webpack-assets-manifest": "^1.0.0",
    "webpack-dev-middleware": "~2.0.4",
    "webpack-hot-middleware": "~2.22.3",
    "webpack-merge": "~4.1.4",
    "yargs": "~11.0.0"
  },
  "dependencies": {
    "jquery": "^3.3.1",
    "slick-carousel": "^1.8.1",
    "popper.js": "^1.14.7"
  }

我做错了什么?

【问题讨论】:

  • 错误提供的链接中有表格显示node-sass v4.8.3 支持的节点版本。升级node-sass或降级节点
  • 抱歉,我粘贴了错误消息 Module build failed: ModuleBuildError: Module build failed: Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (72) 更多有关支持哪些环境的信息,请参阅:github.com/sass/node-sass/releases/tag/v4.9.4 那是一个测试;)
  • 还是一样。支持的最高节点版本是v10,您正在使用节点v12

标签: node.js webpack sass yarnpkg package.json


【解决方案1】:

我使用的是 OSX 最新版本(10.14.4 (18E226)) 和节点 12。

在使用 node-sass 4.11 时,我在尝试 npm installnpm rebuild(link) 时遇到了 g++ 错误(../src/create_string.cpp:17:25: error: no matching constructor for initialization of 'v8::String::Utf8Value'),这不起作用。

我通过将 node-sass 更新到 4.12(npm install node-sass) 解决了这个问题,因为 node-sass 上的 github issue 表示对节点 12 的支持是在 4.12 版本中实现的。

【讨论】:

  • 更糟糕的是,这里提到的步骤对我来说失败了,问题与问题相同。
  • @Naman 检查是否有另一个依赖于node-sass@4.11 的依赖项。我有一个旧版本的@rails/webpacker,它依赖于"node-sass": "^4.11.0",并且运行yarn upgrade @rails/webpacker 修复了我的构建。您可以通过搜索您的yarn.lockpackage-lock.json 来检查它
  • 有史以来最好的答案,由于 Node sass 失败,每个 npm 我都会在我们当前的环境中让我头疼。
【解决方案2】:

这对我有用。将您的节点版本降级到 10.16.0 节点 12 仍然存在一些问题

【讨论】:

  • node 13.7.0 也有这个问题。安装节点 10.18 解决了这个问题,但还有另一个失败 ../src/sass_types/list.cpp:28:19: error: no matching function for call to 'sass_make_list'。将node-sass 依赖更新到最新的 4.13.1 对节点 13.7 和 10.18 都没有帮助
  • 通过在切换节点版本时删除 project-local node_modules 来修复另一个问题,以消除失败构建的剩余部分。
【解决方案3】:

将 node-sass 升级到 4.12.0 即可解决问题。

【讨论】:

  • 更多信息:node-sass Readme 表示“支持的 Node.js 版本因版本而异,请查阅版本页面。”
【解决方案4】:

节点 12 在运行npm install node-sass 时出现此问题,将节点降级到 10.16 有效

【讨论】:

  • 更多信息:node-sass Readme 表示“支持的 Node.js 版本因版本而异,请查阅版本页面。”
【解决方案5】:

对我来说,this 解决方案有效。 步骤如下:

  1. 转到 node-sass 文件夹(它可以是“../node_modules/node-sass/src”或其他地方,例如对于 Angular,它位于“../node_modules/@angular-devkit/build- angular/node_modules/node-sass/src") 你可以在日志中找到位置:
  2. 打开 create_string.cpp
  3. v8::String::Utf8Value string(value); 更改为v8::String::Utf8Value string(v8::Isolate::GetCurrent(), value);

如果找不到“node-sass”文件夹,请重新运行“npm install”,并且当您在控制台中看到 node-sass 日志时,请使用 ctrl+c 终止进程。

【讨论】:

  • 升级到 node-sass 4.12.x 或 4.13.x 并没有解决我的问题,而且我的文件中不存在上述内容,其中包含以下内容: `` char* create_string(Nan ::MaybeLocal<:value> maybevalue) { v8::Local<:value> 值; if (maybevalue.ToLocal(&value)) { if (value->IsNull() || !value->IsString()) { return 0; } } 其他 { 返回 0; } Nan::Utf8String 字符串(值); char *str = (char *)malloc(string.length() + 1); strcpy(str, *string);返回字符串; } ```
  • 唯一有效的是switch to Node version 11.15.0
【解决方案6】:

如果有人使用 Amazon EC2 AMI 映像,请按照以下说明进行操作

  1. 仅从https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html 安装 nvm
  2. nvm ls-remote
  3. nvm install v10.16.0

node-sass 构建将根据您的 AMI 映像成功。

【讨论】:

    猜你喜欢
    • 2022-06-14
    • 2020-03-11
    • 1970-01-01
    • 2018-05-06
    • 2021-03-26
    • 2020-01-25
    • 2016-09-16
    • 2019-02-14
    • 1970-01-01
    相关资源
    最近更新 更多