在 Apple M1 (Big Sur) 上使用 node-gyp 安装本机 Node.js 附加组件时出错
Error installing native Node.js add-on with node-gyp on Apple M1 (Big Sur)
我正在使用 yarn
安装包,包括 asset-hash, which depends on metrohash。
我经常运行出现以下错误:
yarn install v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[-/11] ⠠ waiting...
[10/11] ⠠ metrohash
error /Users/johndoe/Projects/my-project/node_modules/metrohash: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/johndoe/Projects/my-project/node_modules/metrohash
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@15.10.0 | darwin | arm64
gyp info spawn /usr/bin/python2
gyp info spawn args [
gyp info spawn args '/Users/johndoe/Projects/my-project/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/johndoe/Projects/my-project/node_modules/metrohash/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/johndoe/Projects/my-project/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/johndoe/.node-gyp/15.10.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/johndoe/.node-gyp/15.10.0',
gyp info spawn args '-Dnode_gyp_dir=/Users/johndoe/Projects/my-project/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/johndoe/.node-gyp/15.10.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/johndoe/Projects/my-project/node_modules/metrohash',
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 args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
CXX(target) Release/obj.target/metrohash/src/metrohash_wrapper.o
CXX(target) Release/obj.target/metrohash/src/metrohash128.o
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
CXX(target) Release/obj.target/metrohash/src/metrohash128crc.o
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
In file included from ../src/metrohash128crc.cpp:27:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/nmmintrin.h:15:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/smmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/tmmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/pmmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/emmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/xmmintrin.h:13:
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:5: error: use of undeclared identifier '__builtin_ia32_emms'; did you mean '__builtin_isless'?
__builtin_ia32_emms();
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:5: note: '__builtin_isless' declared here
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:25: error: too few arguments to function call, expected 2, have 0
__builtin_ia32_emms();
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:50:19: error: use of undeclared identifier '__builtin_ia32_vec_init_v2si'
return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:67:12: error: use of undeclared identifier '__builtin_ia32_vec_ext_v2si'
return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:129:19: error: use of undeclared identifier '__builtin_ia32_packsswb'
return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:159:19: error: use of undeclared identifier '__builtin_ia32_packssdw'
return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:189:19: error: use of undeclared identifier '__builtin_ia32_packuswb'
return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:216:19: error: use of undeclared identifier '__builtin_ia32_punpckhbw'
return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:239:19: error: use of undeclared identifier '__builtin_ia32_punpckhwd'
return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:260:19: error: use of undeclared identifier '__builtin_ia32_punpckhdq'
return (__m64)__builtin_ia32_punpckhdq((__v2si)__m1, (__v2si)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:287:19: error: use of undeclared identifier '__builtin_ia32_punpcklbw'
return (__m64)__builtin_ia32_punpcklbw((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:310:19: error: use of undeclared identifier '__builtin_ia32_punpcklwd'
return (__m64)__builtin_ia32_punpcklwd((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:331:19: error: use of undeclared identifier '__builtin_ia32_punpckldq'
return (__m64)__builtin_ia32_punpckldq((__v2si)__m1, (__v2si)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: error: use of undeclared identifier '__builtin_ia32_paddb'; did you mean '__builtin_arm_addg'?
return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: error: first argument of MTE builtin function must be a pointer ('__v8qi' (vector of 8 'char' values) invalid)
return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
^ ~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:373:19: error: use of undeclared identifier '__builtin_ia32_paddw'; did you mean '__builtin_arm_addg'?
return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:373:19: error: first argument of MTE builtin function must be a pointer ('__v4hi' (vector of 4 'short' values) invalid)
return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
^ ~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:394:19: error: use of undeclared identifier '__builtin_ia32_paddd'; did you mean '__builtin_arm_addg'?
return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:394:19: error: first argument of MTE builtin function must be a pointer ('__v2si' (vector of 2 'int' values) invalid)
return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
^ ~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/metrohash/src/metrohash128crc.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/johndoe/Projects/my-project/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (node:events:378:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.3.0
gyp ERR! command "/Users/johndoe/.nvm/versions/node/v15.10.0/bin/node" "/Users/johndoe/Projects/my-project/node_modules/metrohash/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/johndoe/Projects/my-project/node_modules/metrohash
我正在使用
- MacBook Pro、苹果 M1
- macOS 大苏尔,11.2.2
- 节点 15.10.0
- 纱线 1.22.10
到目前为止我尝试了什么
- 尝试了其他节点版本 12 和 14
- 运行
xcode-select --install
,删除该工具并重新安装
- 运行
brew update
和 brew upgrade
- 使用 Rosetta 执行终端
我认为错误可能与 Apple M1 芯片或最新的 Big Sur 更新有关。
非常感谢任何帮助。
在同事的帮助下我可以修复错误。
我不得不卸载 brew 并使用 Rosetta 重新安装它。然后我也使用 Rosetta 模式下的终端重新安装了 node 和 yarn。
请将 node-sass 版本与您的节点版本
进行比较
我在 macOS 12.1 Monterey 上遇到了同样的问题,这是由 node-sass-chokidar 引起的。当我从旧的 NodeJS 切换到版本 16 LTS 时,我遇到了这个问题。
要解决我的问题:
- 从 package.json
中删除了节点-sass-chokidar
- 已删除node_modules
- 是否安装了 yarn
- 用 yarn 添加节点-sass
添加了节点-sass
我还需要在 package.json 的“脚本”中更改这些行。
发件人:
"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src /",
"watch-css": "npm 运行 build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
收件人:
"build-css": "node-sass --include-path ./src --include-path ./node_modules src/ -o src/" ,
"watch-css": "npm 运行 build-css && node-sass --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
完成后一切 运行 都很好。
有人谈论使用 node-sass 而不是 node-sass-chokidar (https://pretagteam.com/question/remove-nodesass-from-my-react-project-which-uses-createreactapp) 的效率只是为了完整性,但它似乎并没有影响我的设置。
我正在使用 yarn
安装包,包括 asset-hash, which depends on metrohash。
我经常运行出现以下错误:
yarn install v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[-/11] ⠠ waiting...
[10/11] ⠠ metrohash
error /Users/johndoe/Projects/my-project/node_modules/metrohash: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/johndoe/Projects/my-project/node_modules/metrohash
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@15.10.0 | darwin | arm64
gyp info spawn /usr/bin/python2
gyp info spawn args [
gyp info spawn args '/Users/johndoe/Projects/my-project/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/johndoe/Projects/my-project/node_modules/metrohash/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/johndoe/Projects/my-project/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/johndoe/.node-gyp/15.10.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/johndoe/.node-gyp/15.10.0',
gyp info spawn args '-Dnode_gyp_dir=/Users/johndoe/Projects/my-project/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/johndoe/.node-gyp/15.10.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/johndoe/Projects/my-project/node_modules/metrohash',
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 args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
CXX(target) Release/obj.target/metrohash/src/metrohash_wrapper.o
CXX(target) Release/obj.target/metrohash/src/metrohash128.o
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
CXX(target) Release/obj.target/metrohash/src/metrohash128crc.o
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
In file included from ../src/metrohash128crc.cpp:27:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/nmmintrin.h:15:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/smmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/tmmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/pmmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/emmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/xmmintrin.h:13:
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:5: error: use of undeclared identifier '__builtin_ia32_emms'; did you mean '__builtin_isless'?
__builtin_ia32_emms();
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:5: note: '__builtin_isless' declared here
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:25: error: too few arguments to function call, expected 2, have 0
__builtin_ia32_emms();
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:50:19: error: use of undeclared identifier '__builtin_ia32_vec_init_v2si'
return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:67:12: error: use of undeclared identifier '__builtin_ia32_vec_ext_v2si'
return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:129:19: error: use of undeclared identifier '__builtin_ia32_packsswb'
return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:159:19: error: use of undeclared identifier '__builtin_ia32_packssdw'
return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:189:19: error: use of undeclared identifier '__builtin_ia32_packuswb'
return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:216:19: error: use of undeclared identifier '__builtin_ia32_punpckhbw'
return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:239:19: error: use of undeclared identifier '__builtin_ia32_punpckhwd'
return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:260:19: error: use of undeclared identifier '__builtin_ia32_punpckhdq'
return (__m64)__builtin_ia32_punpckhdq((__v2si)__m1, (__v2si)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:287:19: error: use of undeclared identifier '__builtin_ia32_punpcklbw'
return (__m64)__builtin_ia32_punpcklbw((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:310:19: error: use of undeclared identifier '__builtin_ia32_punpcklwd'
return (__m64)__builtin_ia32_punpcklwd((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:331:19: error: use of undeclared identifier '__builtin_ia32_punpckldq'
return (__m64)__builtin_ia32_punpckldq((__v2si)__m1, (__v2si)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: error: use of undeclared identifier '__builtin_ia32_paddb'; did you mean '__builtin_arm_addg'?
return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: error: first argument of MTE builtin function must be a pointer ('__v8qi' (vector of 8 'char' values) invalid)
return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
^ ~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:373:19: error: use of undeclared identifier '__builtin_ia32_paddw'; did you mean '__builtin_arm_addg'?
return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:373:19: error: first argument of MTE builtin function must be a pointer ('__v4hi' (vector of 4 'short' values) invalid)
return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
^ ~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:394:19: error: use of undeclared identifier '__builtin_ia32_paddd'; did you mean '__builtin_arm_addg'?
return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:394:19: error: first argument of MTE builtin function must be a pointer ('__v2si' (vector of 2 'int' values) invalid)
return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
^ ~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/metrohash/src/metrohash128crc.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/johndoe/Projects/my-project/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (node:events:378:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.3.0
gyp ERR! command "/Users/johndoe/.nvm/versions/node/v15.10.0/bin/node" "/Users/johndoe/Projects/my-project/node_modules/metrohash/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/johndoe/Projects/my-project/node_modules/metrohash
我正在使用
- MacBook Pro、苹果 M1
- macOS 大苏尔,11.2.2
- 节点 15.10.0
- 纱线 1.22.10
到目前为止我尝试了什么
- 尝试了其他节点版本 12 和 14
- 运行
xcode-select --install
,删除该工具并重新安装 - 运行
brew update
和brew upgrade
- 使用 Rosetta 执行终端
我认为错误可能与 Apple M1 芯片或最新的 Big Sur 更新有关。
非常感谢任何帮助。
在同事的帮助下我可以修复错误。
我不得不卸载 brew 并使用 Rosetta 重新安装它。然后我也使用 Rosetta 模式下的终端重新安装了 node 和 yarn。
请将 node-sass 版本与您的节点版本
进行比较我在 macOS 12.1 Monterey 上遇到了同样的问题,这是由 node-sass-chokidar 引起的。当我从旧的 NodeJS 切换到版本 16 LTS 时,我遇到了这个问题。
要解决我的问题:
- 从 package.json 中删除了节点-sass-chokidar
- 已删除node_modules
- 是否安装了 yarn
- 用 yarn 添加节点-sass 添加了节点-sass
我还需要在 package.json 的“脚本”中更改这些行。
发件人:
"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src /", "watch-css": "npm 运行 build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
收件人:
"build-css": "node-sass --include-path ./src --include-path ./node_modules src/ -o src/" , "watch-css": "npm 运行 build-css && node-sass --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
完成后一切 运行 都很好。 有人谈论使用 node-sass 而不是 node-sass-chokidar (https://pretagteam.com/question/remove-nodesass-from-my-react-project-which-uses-createreactapp) 的效率只是为了完整性,但它似乎并没有影响我的设置。