开发者问题收集

npm install 与 node-sass 和 node-gyp 一起失败

2020-05-25
15163

当我使用 Angular 在我的项目 ionic 上安装 npm 时。node-sass/node-gyp 安装失败 错误显示如下:

$ npm install

[email protected] install C:\Users\d\Documents\project\app\node_modules\node-sass node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.10.0/win32-x64-72_binding.node Cannot download " https://github.com/sass/node-sass/releases/download/v4.10.0/win32-x64-72_binding.node ":

HTTP error 404 Not Found

Hint: If github.com is not accessible in your location try setting a proxy via HTTP_PROXY, e.g.

  export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

  npm config set proxy http://example.com:8080

[email protected] postinstall C:\Users\d\Documents\project\app\node_modules\node-sass node scripts/build.js

Building: C:\Program Files\nodejs\node.exe C:\Users\d\Documents\project\app\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library= gyp info it worked if it ends with ok gyp verb cli [ gyp verb cli 'C:\Program Files\nodejs\node.exe', gyp verb cli
'C:\Users\d\Documents\project\app\node_modules\node-gyp\bin\node-gyp.js', gyp verb cli 'rebuild', gyp verb cli '--verbose', gyp verb cli
'--libsass_ext=', gyp verb cli '--libsass_cflags=', gyp verb cli
'--libsass_ldflags=', gyp verb cli '--libsass_library=' gyp verb cli ] gyp info using [email protected] gyp info using [email protected] | win32 | x64 gyp verb command rebuild [] gyp verb command clean [] gyp verb clean removing "build" directory gyp verb command configure [] gyp verb check python checking for Python executable "C:\Users\d.windows-build-tools\python27\python.exe" in the PATH gyp verb which failed Error: not found: C:\Users\d.windows-build-tools\python27\python.exe gyp verb which failed at getNotFoundError (C:\Users\d\Documents\project\app\node_modules\which\which.js:13:12) gyp verb which failed at F (C:\Users\d\Documents\project\app\node_modules\which\which.js:68:19) gyp verb which failed at E (C:\Users\d\Documents\project\app\node_modules\which\which.js:80:29) gyp verb which failed at C:\Users\d\Documents\project\app\node_modules\which\which.js:89:16 gyp verb which failed at C:\Users\d\Documents\project\app\node_modules\isexe\index.js:42:5 gyp verb which failed at C:\Users\d\Documents\project\app\node_modules\isexe\windows.js:36:5 gyp verb which failed at FSReqCallback.oncomplete (fs.js:158:21) gyp verb which failed C:\Users\d.windows-build-tools\python27\python.exe Error: not found: C:\Users\d.windows-build-tools\python27\python.exe gyp verb which failed at getNotFoundError (C:\Users\d\Documents\project\app\node_modules\which\which.js:13:12) gyp verb which failed at F (C:\Users\d\Documents\project\app\node_modules\which\which.js:68:19) gyp verb which failed at E (C:\Users\d\Documents\project\app\node_modules\which\which.js:80:29) gyp verb which failed at C:\Users\d\Documents\project\app\node_modules\which\which.js:89:16 gyp verb which failed at C:\Users\d\Documents\project\app\node_modules\isexe\index.js:42:5 gyp verb which failed at C:\Users\d\Documents\project\app\node_modules\isexe\windows.js:36:5 gyp verb which failed at FSReqCallback.oncomplete (fs.js:158:21) { gyp verb which failed stack: 'Error: not found: C:\Users\d\.windows-build-tools\python27\python.exe\n' + gyp verb which failed ' at getNotFoundError (C:\Users\d\Documents\project\app\node_modules\which\which.js:13:12)\n' + gyp verb which failed ' at F (C:\Users\d\Documents\project\app\node_modules\which\which.js:68:19)\n' + gyp verb which failed ' at E (C:\Users\d\Documents\project\app\node_modules\which\which.js:80:29)\n' + gyp verb which failed ' at C:\Users\d\Documents\project\app\node_modules\which\which.js:89:16\n' + gyp verb which failed ' at C:\Users\d\Documents\project\app\node_modules\isexe\index.js:42:5\n' + gyp verb which failed ' at C:\Users\d\Documents\project\app\node_modules\isexe\windows.js:36:5\n' + gyp verb which failed ' at FSReqCallback.oncomplete (fs.js:158:21)', gyp verb which failed code: 'ENOENT' gyp verb which failed } gyp verb could not find "C:\Users\d.windows-build-tools\python27\python.exe". checking python launcher gyp verb could not find "C:\Users\d.windows-build-tools\python27\python.exe". guessing location gyp verb ensuring that file exists: C:\Python27\python.exe gyp verb check python version C:\Python27\python.exe -c "import sys; print "2.7.16 gyp verb check python version .%s.%s" % sys.version_info[:3];" returned: %j gyp verb get node dir no --target version specified, falling back to host node version: 12.13.1 gyp verb command install [ '12.13.1' ] gyp verb install input version string "12.13.1" gyp verb install installing version: 12.13.1 gyp verb install --ensure was passed, so won't reinstall if already installed gyp verb install version is already installed, need to check "installVersion" gyp verb got "installVersion" 9 gyp verb needs "installVersion" 9 gyp verb install version is good gyp verb get node dir target node version installed: 12.13.1 gyp verb build dir attempting to create "build" dir: C:\Users\d\Documents\project\app\node_modules\node-sass\build gyp verb build dir "build" dir needed to be created? C:\Users\d\Documents\project\app\node_modules\node-sass\build gyp verb find vs2017 Found installation at: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise gyp verb find vs2017 - Found Microsoft.VisualStudio.Component.Windows10SDK.18362 gyp verb find vs2017 - Found Microsoft.VisualStudio.Component.VC.Tools.x86.x64 gyp verb find vs2017 - Found Microsoft.VisualStudio.VC.MSBuild.Base gyp verb find vs2017 - Using this installation with Windows 10 SDK gyp verb find vs2017 using installation: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise gyp verb build/config.gypi creating config file gyp verb build/config.gypi writing out config file: C:\Users\d\Documents\project\app\node_modules\node-sass\build\config.gypi gyp verb config.gypi checking for gypi file: C:\Users\d\Documents\project\app\node_modules\node-sass\config.gypi gyp verb common.gypi checking for gypi file: C:\Users\d\Documents\project\app\node_modules\node-sass\common.gypi gyp verb gyp gyp format was not specified; forcing "msvs" gyp info spawn C:\Python27\python.exe gyp info spawn args [ gyp info spawn args 'C:\Users\d\Documents\project\app\node_modules\node-gyp\gyp\gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'msvs', gyp info spawn args '-G', gyp info spawn args 'msvs_version=2015', gyp info spawn args '-I', gyp info spawn args
'C:\Users\d\Documents\project\app\node_modules\node-sass\build\config.gypi', gyp info spawn args '-I', gyp info spawn args
'C:\Users\d\Documents\project\app\node_modules\node-gyp\addon.gypi', gyp info spawn args '-I', gyp info spawn args
'C:\Users\d\.node-gyp\12.13.1\include\node\common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args
'-Dvisibility=default', gyp info spawn args
'-Dnode_root_dir=C:\Users\d\.node-gyp\12.13.1', gyp info spawn args
'-Dnode_gyp_dir=C:\Users\d\Documents\project\app\node_modules\node-gyp', gyp info spawn args
'-Dnode_lib_file=C:\Users\d\.node-gyp\12.13.1\<(target_arch)\node.lib', gyp info spawn args
'-Dmodule_root_dir=C:\Users\d\Documents\project\app\node_modules\node-sass', 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
'C:\Users\d\Documents\project\app\node_modules\node-sass\build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] gyp verb command build [] gyp verb build type Release gyp verb architecture x64 gyp verb node dev dir C:\Users\d.node-gyp\12.13.1 gyp verb found first Solution file build/binding.sln gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe gyp info spawn args [ gyp info spawn args 'build/binding.sln', gyp info spawn args '/nologo', gyp info spawn args
'/p:Configuration=Release;Platform=x64' gyp info spawn args ] gyp ERR! UNCAUGHT EXCEPTION gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\15.0\Bin\MSBuild.exe ENOENT gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19) gyp ERR! stack at onErrorNT (internal/child_process.js:456:16) gyp ERR! stack at processTicksAndRejections (internal/process/task_queues.js:80:21) gyp ERR! System Windows_NT 10.0.18362 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\d\Documents\project\app\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd C:\Users\d\Documents\project\app\node_modules\node-sass gyp ERR! node -v v12.13.1 gyp ERR! node-gyp -v v3.8.0 gyp ERR! This is a bug in node-gyp . gyp ERR! Try to update node-gyp and file an Issue if it does not help: gyp ERR!
https://github.com/nodejs/node-gyp/issues Build failed with error code: 7 npm WARN [email protected] requires a peer of @angular/common@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] requires a peer of @angular/core@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] requires a peer of @angular/core@^8.2.14 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] requires a peer of rxjs@~6.5.4 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of core-js@^3.6.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected] : wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\node-sass): npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] postinstall: node scripts/build.js npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

added 83 packages from 166 contributors, removed 618 packages, updated 191 packages and audited 1597 packages in 52.38s found 2966 vulnerabilities (2197 low, 11 moderate, 756 high, 2 critical) run npm audit fix to fix them, or npm audit for details

package.json

{
  "name": "project",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "7.1.4",
    "@angular/cdk": "7.1.0",
    "@angular/common": "7.1.4",
    "@angular/core": "7.1.4",
    "@angular/forms": "7.1.4",
    "@angular/http": "7.1.4",
    "@angular/platform-browser": "7.1.4",
    "@angular/platform-browser-dynamic": "7.1.4",
    "@angular/router": "7.1.4",
    "@fortawesome/fontawesome-free": "5.12.0",
    "@ionic-native/core": "5.1.0",
    "@ionic-native/file": "5.1.0",
    "@ionic-native/file-path": "5.1.0",
    "@ionic-native/file-transfer": "5.1.0",
    "@ionic-native/in-app-browser": "5.5.1",
    "@ionic-native/native-page-transitions": "5.5.1",
    "@ionic-native/splash-screen": "5.1.0",
    "@ionic-native/status-bar": "5.1.0",
    "@ionic/angular": "4.0.0-beta.15",
    "@kolkov/angular-editor": "^0.15.1",
    "@progress/kendo-angular-buttons": "^4.0.0",
    "@progress/kendo-angular-charts": "3.9.0",
    "@progress/kendo-angular-dateinputs": "2 - 3",
    "@progress/kendo-angular-dropdowns": "2 - 3",
    "@progress/kendo-angular-excel-export": "1 - 2",
    "@progress/kendo-angular-grid": "^3.14.4",
    "@progress/kendo-angular-inputs": "2 - 5",
    "@progress/kendo-angular-intl": "^1.0.0",
    "@progress/kendo-angular-l10n": "^1.1.0",
    "@progress/kendo-angular-popup": "^2.0.0",
    "@progress/kendo-data-query": "^1.0.0",
    "@progress/kendo-drawing": "^1.0.0",
    "@progress/kendo-theme-default": "latest",
    "angular-gridster2": "^7.2.0",
    "angular-ng-autocomplete": "1.1.12",
    "angular-resize-event": "1.2.1",
    "cordova-android": "8.0.0",
    "cordova-ios": "5.0.1",
    "cordova-plugin-device": "2.0.2",
    "cordova-plugin-ionic-webview": "2.3.1",
    "cordova-plugin-splashscreen": "5.0.2",
    "cordova-plugin-statusbar": "2.4.2",
    "cordova-plugin-whitelist": "1.3.3",
    "core-js": "^2.4.1",
    "file-saver": "^2.0.2",
    "hammerjs": "2.0.0",
    "ionic": "4.6.0",
    "jspdf": "^1.5.3",
    "jszip": "^3.2.2",
    "lodash": "4.17.15",
    "moment": "2.24.0",
    "mydatepicker": "2.6.6",
    "ng-select": "1.0.2",
    "ng2-ace-editor": "0.3.9",
    "ngx-bootstrap": "5.3.2",
    "ngx-color-picker": "^5.3.8",
    "ngx-dropzone": "1.2.0",
    "ngx-perfect-scrollbar": "7.2.1",
    "release": "6.0.1",
    "rxjs": "6.3.3",
    "rxjs-compat": "^6.0.0",
    "stream": "0.0.2",
    "tslib": "1.9.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/architect": "0.11.4",
    "@angular-devkit/build-angular": "0.11.4",
    "@angular-devkit/core": "7.1.4",
    "@angular-devkit/schematics": "7.1.4",
    "@angular/cli": "7.1.4",
    "@angular/compiler": "7.1.4",
    "@angular/compiler-cli": "7.1.4",
    "@angular/language-service": "7.1.4",
    "@ionic/angular-toolkit": "1.2.0",
    "@types/node": "10.12.0",
    "@types/jasmine": "2.8.8",
    "@types/jasminewd2": "2.0.3",
    "codelyzer": "4.5.0",
    "jasmine-core": "2.99.1",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "3.1.4",
    "karma-chrome-launcher": "2.2.0",
    "karma-coverage-istanbul-reporter": "2.0.1",
    "karma-jasmine": "1.1.2",
    "karma-jasmine-html-reporter": "0.2.2",
    "protractor": "5.4.0",
    "ts-node": "7.0.0",
    "tslint": "5.12.0",
    "typescript": "3.1.6",
    "@svgdotjs/svg.js": "3.0.16"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "com.telerik.plugins.nativepagetransitions": {},
      "cordova-plugin-inappbrowser": {}
    },
    "platforms": [
      "android",
      "ios"
    ]
  }
}

npm 版本:6.14.4

2个回答

重新安装 Node Js,在安装其中一个页面时,会有一个复选框用于安装额外工具,只需选中它然后单击下一步即可。安装 Node js 后,它会打开一个额外的窗口,要求您按下按键,只需继续即可。完成安装后,请执行上述操作。然后它应该可以正常工作。

Aakash Garg
2020-05-25

Live sass 编译器 我有同样的问题,但花了几个小时后,我使用了 Visual Studio 代码扩展名 Live Sass-compiler ,它解决了我的问题,它将 .scss 代码编译为同一目录中的 .css 文件,只需在组件中导入 .css 文件即可。

Qasim Hussain
2020-10-30