Yarn,node-gyp重建编译错误,node_modules/fsevents:命令失败

40

我正在使用Yarn来管理软件包。

yarn install 出现了错误,无论我使用哪个软件包,但安装看起来已经成功完成,并且文件直接设置在node-modules下。(某种程度上,jquery-ui没有出现在node-modules下)

我已经删除了yarn.lock并重试,但是仍然失败。

有人可以帮忙吗?

我的环境如下:

whitebear$ yarn -v
1.10.1
whitebear$ node -v
v11.0.0
whitebear$ npm -v
6.4.1

package.json

:该文件是 npm(Node.js 包管理器)所需的清单文件,它包含了项目中所有依赖项的元数据。
{
  "devDependencies": {
    "@symfony/webpack-encore": "^0.20.0",
    "bootstrap": "^4.1.3",
    "jquery": "^3.3.1",
    "node-sass": "^4.9.4",
    "popper.js": "^1.14.4",
    "sass-loader": "^7.1.0",
    "webpack-notifier": "^1.6.0"
  },
  "license": "UNLICENSED",
  "private": true,
  "scripts": {
    "dev-server": "encore dev-server",
    "dev": "encore dev",
    "watch": "encore dev --watch",
    "build": "encore production"
  },
  "dependencies": {
    "encore": "^0.0.30-beta",
    "jquery-ui": "^1.12.1",
    "jquery.event.drag": "^2.2.2",
    "slickgrid-es6": "^3.0.1"
  }
}

yarn 的日志 install

whitebearnoMacBook-puro:myinvestlist whitebear$ sudo yarn install
yarn install v1.10.1
[1/4]   Resolving packages...
[2/4]   Fetching packages...
[3/4]   Linking dependencies...
warning " > sass-loader@7.1.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
warning "runway@3.15.47-beta" is missing a bundled dependency "favicon.json". This should be reported to the package maintainer.
[4/4]   Building fresh packages...
[1/4] ⠈ fsevents
[-/4] ⠈ waiting...
[3/4] ⠈ fsevents
warning Error running install script for optional dependency: "/Users/whitebear/CodingWorks/httproot/myinvestlist/node_modules/encore/node_modules/fsevents: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments: 
Directory: /Users/whitebear/CodingWorks/httproot/myinvestlist/node_modules/encore/node_modules/fsevents
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@11.0.0 | darwin | x64
gyp info spawn /usr/bin/python
gyp info spawn args [ '/usr/local/Cellar/node/11.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/whitebear/CodingWorks/httproot/myinvestlist/node_modules/encore/node_modules/fsevents/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/Cellar/node/11.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/whitebear/.node-gyp/11.0.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/whitebear/.node-gyp/11.0.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/Cellar/node/11.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/whitebear/.node-gyp/11.0.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/whitebear/CodingWorks/httproot/myinvestlist/node_modules/encore/node_modules/fsevents',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/fse/fsevents.o
In file included from ../fsevents.cc:6:
../../nan/nan.h:190:32: warning: 'BooleanValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
      || optionsObj->Get(opt)->BooleanValue();
                               ^
/Users/whitebear/.node-gyp/11.0.0/include/node/v8.h:2568:3: note: 'BooleanValue' has been explicitly marked deprecated here
  V8_DEPRECATED(\"Use maybe version\", bool BooleanValue() const);
  ^
/Users/whitebear/.node-gyp/11.0.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
In file included from ../fsevents.cc:6:
../../nan/nan.h:194:32: warning: 'BooleanValue' is deprecated: Use maybe version [-Wdeprecated-declarations]
      && optionsObj->Get(opt)->BooleanValue();
                               ^
/Users/whitebear/.node-gyp/11.0.0/include/node/v8.h:2568:3: note: 'BooleanValue' has been explicitly marked deprecated here
  V8_DEPRECATED(\"Use maybe version\", bool BooleanValue() const);
  ^
/Users/whitebear/.node-gyp/11.0.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
In file included from ../fsevents.cc:6:
../../nan/nan.h:213:31: warning: 'Uint32Value' is deprecated: Use maybe version [-Wdeprecated-declarations]
      ? optionsObj->Get(opt)->Uint32Value()
                              ^
/Users/whitebear/.node-gyp/11.0.0/include/node/v8.h:2571:3: note: 'Uint32Value' has been explicitly marked deprecated here
  V8_DEPRECATED(\"Use maybe version\", uint32_t Uint32Value() const);
  ^
/Users/whitebear/.node-gyp/11.0.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
In file included from ../fsevents.cc:6:
../../nan/nan.h:339:13: error: no member named 'New' in 'v8::String'
    return  _NAN_ERROR(v8::Exception::Error, errmsg);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:319:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                     ~~~~~~~~~~~~^
../../nan/nan.h:343:5: error: no member named 'ThrowException' in namespace 'v8'
    _NAN_THROW_ERROR(v8::Exception::Error, errmsg);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:324:11: note: expanded from macro '_NAN_THROW_ERROR'
      v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \\\n      ~~~~^
../../nan/nan.h:343:5: error: no member named 'New' in 'v8::String'
    _NAN_THROW_ERROR(v8::Exception::Error, errmsg);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:324:26: note: expanded from macro '_NAN_THROW_ERROR'
      v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \\\n                         ^~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:319:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                     ~~~~~~~~~~~~^
../../nan/nan.h:348:9: error: no type named 'ThrowException' in namespace 'v8'
    v8::ThrowException(error);
    ~~~~^
../../nan/nan.h:355:65: error: no member named 'New' in 'v8::String'
    v8::Local<v8::Value> err = v8::Exception::Error(v8::String::New(msg));
                                                    ~~~~~~~~~~~~^
../../nan/nan.h:356:50: error: expected '(' for function-style cast or type construction
    v8::Local<v8::Object> obj = err.As<v8::Object>();
                                       ~~~~~~~~~~^
../../nan/nan.h:356:52: error: expected expression
    v8::Local<v8::Object> obj = err.As<v8::Object>();
                                                   ^
../../nan/nan.h:357:65: error: too few arguments to function call, expected 2, have 1
    obj->Set(v8::String::New(\"code\"), v8::Int32::New(errorNumber));
                                      ~~~~~~~~~~~~~~            ^
/Users/whitebear/.node-gyp/11.0.0/include/node/v8.h:3154:3: note: 'New' declared here
  static Local<Integer> New(Isolate* isolate, int32_t value);
  ^
In file included from ../fsevents.cc:6:
../../nan/nan.h:357:26: error: no member named 'New' in 'v8::String'
    obj->Set(v8::String::New(\"code\"), v8::Int32::New(errorNumber));
             ~~~~~~~~~~~~^
../../nan/nan.h:369:12: error: no member named 'New' in 'v8::String'
    return _NAN_ERROR(v8::Exception::TypeError, errmsg);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:319:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                     ~~~~~~~~~~~~^
../../nan/nan.h:373:5: error: no member named 'ThrowException' in namespace 'v8'
    _NAN_THROW_ERROR(v8::Exception::TypeError, errmsg);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:324:11: note: expanded from macro '_NAN_THROW_ERROR'
      v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \\\n      ~~~~^
../../nan/nan.h:373:5: error: no member named 'New' in 'v8::String'
    _NAN_THROW_ERROR(v8::Exception::TypeError, errmsg);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:324:26: note: expanded from macro '_NAN_THROW_ERROR'
      v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \\\n                         ^~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:319:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                     ~~~~~~~~~~~~^
../../nan/nan.h:377:12: error: no member named 'New' in 'v8::String'
    return _NAN_ERROR(v8::Exception::RangeError, errmsg);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:319:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                     ~~~~~~~~~~~~^
../../nan/nan.h:381:5: error: no member named 'ThrowException' in namespace 'v8'
    _NAN_THROW_ERROR(v8::Exception::RangeError, errmsg);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:324:11: note: expanded from macro '_NAN_THROW_ERROR'
      v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \\\n      ~~~~^
../../nan/nan.h:381:5: error: no member named 'New' in 'v8::String'
    _NAN_THROW_ERROR(v8::Exception::RangeError, errmsg);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:324:26: note: expanded from macro '_NAN_THROW_ERROR'
      v8::ThrowException(_NAN_ERROR(fun, errmsg));                             \\\n                         ^~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan.h:319:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
                                     ~~~~~~~~~~~~^
../../nan/nan.h:406:13: error: no member named 'smalloc' in namespace 'node'
    , node::smalloc::FreeCallback callback
      ~~~~~~^
../../nan/nan.h:141:71: note: expanded from macro 'NAN_INLINE'
# define NAN_INLINE(declarator) inline __attribute__((always_inline)) declarator
                                                                      ^~~~~~~~~~
../../nan/nan.h:416:12: error: no matching function for call to 'New'
    return node::Buffer::New(data, size);
           ^~~~~~~~~~~~~~~~~
/Users/whitebear/.node-gyp/11.0.0/include/node/node_buffer.h:49:40: note: candidate function not viable: no known conversion from 'char *' to 'v8::Isolate *' for 1st argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/whitebear/.node-gyp/11.0.0/include/node/node_buffer.h:52:40: note: candidate function not viable: no known conversion from 'char *' to 'v8::Isolate *' for 1st argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/whitebear/.node-gyp/11.0.0/include/node/node_buffer.h:64:40: note: candidate function not viable: requires 3 arguments, but 2 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/whitebear/.node-gyp/11.0.0/include/node/node_buffer.h:57:40: note: candidate function not viable: requires 5 arguments, but 2 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
In file included from ../fsevents.cc:6:
../../nan/nan.h:420:12: error: no matching function for call to 'New'
    return node::Buffer::New(size);
           ^~~~~~~~~~~~~~~~~
/Users/whitebear/.node-gyp/11.0.0/include/node/node_buffer.h:49:40: note: candidate function not viable: requires 2 arguments, but 1 was provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/whitebear/.node-gyp/11.0.0/include/node/node_buffer.h:52:40: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/whitebear/.node-gyp/11.0.0/include/node/node_buffer.h:64:40: note: candidate function not viable: requires 3 arguments, but 1 was provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/whitebear/.node-gyp/11.0.0/include/node/node_buffer.h:57:40: note: candidate function not viable: requires 5 arguments, but 1 was provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
In file included from ../fsevents.cc:6:
../../nan/nan.h:427:26: error: no member named 'Use' in namespace 'node::Buffer'
    return node::Buffer::Use(data, size);
           ~~~~~~~~~~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
3 warnings and 20 errors generated.
make: *** [Release/obj.target/fse/fsevents.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/Cellar/node/11.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command \"/usr/local/Cellar/node/11.0.0/bin/node\" \"/usr/local/Cellar/node/11.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"rebuild\"
gyp ERR! cwd /Users/whitebear/CodingWorks/httproot/myinvestlist/node_modules/encore/node_modules/fsevents
gyp ERR! node -v v11.0.0
✨  Done in 87.84s.

3
你解决了吗?怎么解决的? - Tasos Anesiadis
6个回答

40

我遇到了类似的问题,删除 node_modules 并删除 yarn.lock 对我有用。

sudo rm -r node_modules && rm yarn.lock && yarn install

不确定是否卡在某些冲突上。


3
“Dependencies are hard mk.”这句话的意思是“依赖关系很难处理”。我不太愿意提出建议,但是确实清理旧的node模块可以起到作用。命令是sudo rm -r node_modules && rm yarn.lock && yarn install。但是我还是要警告大家,请谨记sudo rm -r这个命令需要高级权限并且会递归删除,输入错误可能会导致无法恢复的丢失工作,除非有像git这样的版本管理系统。 - jasonleonhard
我尝试了同样的方法,但对我来说没有起作用,因为我是在尝试升级我的项目。 - undefined

14

这就是正确的方式! - Crysfel
对我来说不起作用 - undefined

8
将以下内容添加到您的package.json文件中,然后重新运行yarn(或yarn install):
"resolutions": {
  "**/**/fsevents": "^1.2.9"
}

来源: https://github.com/yarnpkg/yarn/issues/5962#issuecomment-491934806

这篇文章讨论了在使用Yarn时可能遇到的一个问题:在Windows上,当使用命令“yarn add package-name”添加依赖项时,可能会收到一个错误消息:“无法正确识别文件名、目录名或卷标的语法”。这个问题通常是由于Windows上的路径长度限制引起的。解决方法是缩短路径或使用UNC路径。

我现在可能会选择^2.3.3 - undefined

3
我将 node 版本降级至 v8.16.0。你可以使用 n 命令来完成。这对我很有效。
在此之前,请确保删除之前的版本。
brew uninstall node

安装降级版本
brew install n
n 8.16.0

如果它不起作用,尝试降级/升级您的节点版本。"最初的回答"

为什么选择8.16.0版本?在此版本之后有什么变化? - Reverse Engineered
这是对我有效的版本。但是,根据大家的回答,我认为问题可能是由于节点/纱线版本与已经存在的软件包兼容性引起的。因此,我将编辑我的答案。 - Gilg Him
这是一个巨大的过度设计。 - stkvtflw
详细说明 @stkvtflw - Gilg Him
过度杀伤,主要是因为您需要重新安装Node。这不是最好的方法,但如果它解决了问题,那就好奇一下使用nvm更改Node版本是否可以解决该问题。 - konsalex
不确定这是一个明智的回答,v16及以下的版本已不再维护。 - undefined

2

0

对我来说,降级到 Node 12 LTS 版本解决了问题。我使用了 nvm


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接