Npm install 在每次安装时都会重建 .node-gyp

Zet*_*eth 5 fsevents node.js npm node-gyp

我每次都会收到此消息npm install

\n\n
> fsevents@1.2.4 install /Users/USERNAME/URL/TO/GULP/FILE/node_modules/fsevents\n> node install\n\n[fsevents] Success: "/Users/USERNAME/URL/TO/GULP/FILE/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed\nPass --update-binary to reinstall or --build-from-source to recompile\n\n> node-sass@3.13.1 install /Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-sass\n> node scripts/install.js\n\nDownloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/darwin-x64-57_binding.node\nCannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/darwin-x64-57_binding.node":\n\nHTTP error 404 Not Found\n\nHint: If github.com is not accessible in your location\n      try setting a proxy via HTTP_PROXY, e.g.\n\n      export HTTP_PROXY=http://example.com:1234\n\nor configure npm proxy via\n\n      npm config set proxy http://example.com:8080\n\n> node-sass@3.13.1 postinstall /Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-sass\n> node scripts/build.js\n\nBuilding: /usr/local/bin/node /Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=\ngyp info it worked if it ends with ok\ngyp verb cli [ \'/usr/local/bin/node\',\ngyp verb cli   \'/Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-gyp/bin/node-gyp.js\',\ngyp verb cli   \'rebuild\',\ngyp verb cli   \'--verbose\',\ngyp verb cli   \'--libsass_ext=\',\ngyp verb cli   \'--libsass_cflags=\',\ngyp verb cli   \'--libsass_ldflags=\',\ngyp verb cli   \'--libsass_library=\' ]\ngyp info using node-gyp@3.7.0\ngyp info using node@8.11.1 | darwin | x64\ngyp verb command rebuild []\ngyp verb command clean []\ngyp verb clean removing "build" directory\ngyp verb command configure []\ngyp verb check python checking for Python executable "python2" in the PATH\ngyp verb `which` failed Error: not found: python2\ngyp verb `which` failed     at getNotFoundError (/Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:13:12)\ngyp verb `which` failed     at F (/Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:68:19)\ngyp verb `which` failed     at E (/Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:80:29)\ngyp verb `which` failed     at /Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:89:16\ngyp verb `which` failed     at /Users/USERNAME/URL/TO/GULP/FILE/node_modules/isexe/index.js:42:5\ngyp verb `which` failed     at /Users/USERNAME/URL/TO/GULP/FILE/node_modules/isexe/mode.js:8:5\ngyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)\ngyp verb `which` failed  python2 { Error: not found: python2\ngyp verb `which` failed     at getNotFoundError (/Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:13:12)\ngyp verb `which` failed     at F (/Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:68:19)\ngyp verb `which` failed     at E (/Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:80:29)\ngyp verb `which` failed     at /Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:89:16\ngyp verb `which` failed     at /Users/USERNAME/URL/TO/GULP/FILE/node_modules/isexe/index.js:42:5\ngyp verb `which` failed     at /Users/USERNAME/URL/TO/GULP/FILE/node_modules/isexe/mode.js:8:5\ngyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)\ngyp verb `which` failed   stack: \'Error: not found: python2\\n    at getNotFoundError (/Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:13:12)\\n    at F (/Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:68:19)\\n    at E (/Users/USERNAME/URL/TO/GULP/FILE/node_modules/    which/which.js:80:29)\\n    at /Users/USERNAME/URL/TO/GULP/FILE/node_modules/which/which.js:89:16\\n    at /Users/USERNAME/URL/TO/GULP/FILE/node_modules/isexe/index.js:42:5\\n    at /Users/USERNAME/URL/TO/GULP/FILE/node_modules/isexe/mode.js:8:5\\n    at FSReqWrap.oncomplete (fs.js:152:21)\',\ngyp verb `which` failed   code: \'ENOENT\' }\ngyp verb check python checking for Python executable "python" in the PATH\ngyp verb `which` succeeded python /usr/bin/python\ngyp verb check python version `/usr/bin/python -c "import platform; print(platform.python_version());"` returned: "2.7.10\\n"\ngyp verb get node dir no --target version specified, falling back to host node version: 8.11.1\ngyp verb command install [ \'8.11.1\' ]\ngyp verb install input version string "8.11.1"\ngyp verb install installing version: 8.11.1\ngyp verb install --ensure was passed, so won\'t reinstall if already installed\ngyp verb install version is already installed, need to check "installVersion"\ngyp verb got "installVersion" 9\ngyp verb needs "installVersion" 9\ngyp verb install version is good\ngyp verb get node dir target node version installed: 8.11.1\ngyp verb build dir attempting to create "build" dir: /Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-sass/build\ngyp verb build dir "build" dir needed to be created? /Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-sass/build\ngyp verb build/config.gypi creating config file\ngyp verb build/config.gypi writing out config file: /Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-sass/build/config.gypi\ngyp verb config.gypi checking for gypi file: /Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-sass/config.gypi\ngyp verb common.gypi checking for gypi file: /Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-sass/common.gypi\ngyp verb gyp gyp format was not specified; forcing "make"\ngyp info spawn /usr/bin/python\ngyp info spawn args [ \'/Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-gyp/gyp/gyp_main.py\',\ngyp info spawn args   \'binding.gyp\',\ngyp info spawn args   \'-f\',\ngyp info spawn args   \'make\',\ngyp info spawn args   \'-I\',\ngyp info spawn args   \'/Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-sass/build/config.gypi\',\ngyp info spawn args   \'-I\',\ngyp info spawn args   \'/Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-gyp/addon.gypi\',\ngyp info spawn args   \'-I\',\ngyp info spawn args   \'/Users/USERNAME/.node-gyp/8.11.1/include/node/common.gypi\',\ngyp info spawn args   \'-Dlibrary=shared_library\',\ngyp info spawn args   \'-Dvisibility=default\',\ngyp info spawn args   \'-Dnode_root_dir=/Users/USERNAME/.node-gyp/8.11.1\',\ngyp info spawn args   \'-Dnode_gyp_dir=/Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-gyp\',\ngyp info spawn args   \'-Dnode_lib_file=/Users/USERNAME/.node-gyp/8.11.1/<(target_arch)/node.lib\',\ngyp info spawn args   \'-Dmodule_root_dir=/Users/USERNAME/URL/TO/GULP/FILE/node_modules/node-sass\',\ngyp info spawn args   \'-Dnode_engine=v8\',\ngyp info spawn args   \'--depth=.\',\ngyp info spawn args   \'--no-parallel\',\ngyp info spawn args   \'--generator-output\',\ngyp info spawn args   \'build\',\ngyp info spawn args   \'-Goutput_dir=.\' ]\ngyp verb command build []\ngyp verb build type Release\ngyp verb architecture x64\ngyp verb node dev dir /Users/USERNAME/.node-gyp/8.11.1\ngyp verb `which` succeeded for `make` /usr/bin/make\ngyp info spawn make\ngyp info spawn args [ \'V=1\', \'BUILDTYPE=Release\', \'-C\', \'build\' ]\n  c++ \'-DNODE_GYP_MODULE_NAME=libsass\' \'-DUSING_UV_SHARED=1\' \'-DUSING_V8_SHARED=1\' \'-DV8_DEPRECATION_WARNINGS=1\' \'-D_DARWIN_USE_64_BIT_INODE=1\' \'-D_LARGEFILE_SOURCE\' \'-D_FILE_OFFSET_BITS=64\' \'-DLIBSASS_VERSION="3.3.6"\' -I/Users/USERNAME/.node-gyp/8.11.1/include/node -I/Users/    USERNAME/.node-gyp/8.11.1/src -I/Users/USERNAME/.node-gyp/8.11.1/deps/openssl/config -I/Users/USERNAME/.node-gyp/8.11.1/deps/openssl/openssl/include -I/Users/USERNAME/.node-gyp/8.11.1/deps/uv/include -I/Users/USERNAME/.node-gyp/8.11.1/deps/zlib -I/Users/USERNAME/.node-gyp/8.11.1/deps/    v8/include -I../src/libsass/include  -Os -gdwarf-2 -mmacosx-version-min=10.7 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=c++11 -stdlib=libc++ -fno-threadsafe-statics -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/ast.o.d.raw       -c -o Release/obj.target/libsass/src/libsass/src/ast.o ../src/libsass/src/ast.cpp\n^Cmake: *** Deleting file `Release/obj.target/libsass/src/libsass/src/ast.o\'\nmake: *** [Release/obj.target/libsass/src/libsass/src/ast.o] Interrupt: 2\nnpm notice created a lockfile as package-lock.json. You should commit this file.\nnpm WARN GulpFileName@1.0.0 No description\nnpm WARN GulpFileName@1.0.0 No repository field.    \n
Run Code Online (Sandbox Code Playgroud)\n\n

我的全局安装包(npm -g ls --depth=0)是这些:

\n\n
/usr/local/lib\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 fsevents@1.2.4\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 gulp@3.9.1\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 gulp-cli@2.0.1\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 jscs@3.0.7\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 n@2.1.8\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 node-gyp@3.7.0\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 node-sass@4.9.0\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 npm@5.10.0\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 vue-cli@2.9.3\n
Run Code Online (Sandbox Code Playgroud)\n\n

npm install当我使用此文件运行时出现错误package.json

\n\n
{\n    "name": "GulpName",\n    "author": "Johnny Bravo",\n    "version": "1.0.0",\n    "license": "GPL-2.0",\n    "dependencies": {},\n    "devDependencies": {\n        "autoprefixer": "^8.6.3",\n        "browserslist": "^3.2.8",\n        "gulp": "^4.0.0",\n        "gulp-concat": "^2.6.1",\n        "gulp-postcss": "^7.0.1",\n        "gulp-sass": "^2.0.0",\n        "gulp-clean-css": "^3.9.4",\n        "gulp-uglify": "^3.0.0"\n    },\n    "browserslist": [\n        "last 2 version",\n        "> 1%",\n        "safari >= 5",\n        "ie >= 8",\n        "chrome >= 34",\n        "ie_mob >= 10",\n        "opera >= 23",\n        "ios >= 7",\n        "ff >= 7",\n        "android >= 4",\n        "bb >= 10"\n    ]\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的尝试:

\n\n
    \n
  • 我尝试删除~/.node-gyp(然后用刷新缓存npm cache verify)。
  • \n
  • 我尝试卸载我可以看到的所有“随机”软件包npm -g ls --depth=0。我有一些phantomjs类似http-server的东西。
  • \n
  • 我尝试在全局范围内node-gyp安装, 希望我不应该在安装过程中执行这些步骤。但我仍然遇到同样的长错误。fseventsnode-sass
  • \n
\n\n

...显然,在我尝试解决这个问题的过程中,我确实rm -rf node_modules package-lock.json跟踪了npm install无数次。

\n\n

我可以看到几个 地方,关于人们遇到类似错误的事情,这是由于一些纱线问题造成的。我还没有使用过任何这样的东西。

\n\n

我真的每次运行时都要忍受这个繁琐而漫长的安装过程吗npm install

\n

Zet*_*eth 8

好吧...我自己想出了大部分。问题是node-sass版本"~2.0.0"太旧了。当我将其提高到 时"4.0.1", 的重新编译就node-gyp消失了。

不过,对于那些想要自己尝试一些事情的新手来说,这是我的过程:

  1. 请记住,您有本地包(在 中package.json)和全局包(通过写入访问:npm -g ls --depth=0.

  2. 您可以按照此答案删除所有全局包。

  3. 然后一次删除一个 devDependency,然后尝试运行,npm install直到愚蠢的错误消失。

我仍然遇到这个错误(我不会解决这个错误,因为我将我的npm install时间减少了一分钟左右,这对我来说已经足够了)。

> fsevents@1.2.4 install /PATH/TO/PACKAGEJSON-FILE/node_modules/fsevents
> node install

[fsevents] Success: "/PATH/TO/PACKAGEJSON-FILE/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> node-sass@4.9.0 install /PATH/TO/PACKAGEJSON-FILE/node_modules/node-sass
> node scripts/install.js

Cached binary found at /Users/REDACTED/.npm/node-sass/4.9.0/darwin-x64-57_binding.node

> node-sass@4.9.0 postinstall /PATH/TO/PACKAGEJSON-FILE/node_modules/node-sass
> node scripts/build.js

Binary found at /PATH/TO/PACKAGEJSON-FILE/node_modules/node-sass/vendor/darwin-x64-57/binding.node
Testing binary
Binary is fine
Run Code Online (Sandbox Code Playgroud)

  • 我的问题也是一样的,使用node-sass。我从版本更新:^4.13.1 -&gt; ^4.14.1,一切正常。谢谢 (2认同)