【问题标题】:Unable to publish my Asp.Net Core + Angular to azure无法将我的 Asp.Net Core + Angular 发布到天蓝色
【发布时间】:2017-04-20 17:24:39
【问题描述】:

我有一个前端带有 angular2 的 asp.net 核心应用程序。我用dotnet new angular 创建了它。

当我尝试将其发布到服务器时,安装依赖项似乎失败:

npm install
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! code ETARGET

npm ERR! notarget No compatible version found: @types/jquery@2.2.1
npm ERR! notarget Valid install targets:
npm ERR! notarget 2.0.41, 2.0.40, 2.0.39, 2.0.38, 2.0.37, 2.0.36, 2.0.35, 2.0.34, 2.0.33, 2.0.32, 1.10.31, 1.10.30, 1.10.29, 1.10.28, 1.10.27, 1.10.26-alpha, 1.10.25-alpha, 1.10.24-alpha, 1.10.23-alpha, 1.10.22-alpha, 1.10.21-alpha, 1.10.20-alpha, 1.10.15-alpha, 1.10.14-alpha, 1.10.8-alpha
npm ERR! notarget 
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget 
npm ERR! notarget It was specified as a dependency of 'AstroWeb'
npm ERR! notarget 

但在本地运行良好。

我的package.json

{
  "name": "AstroWeb",
  "version": "0.0.0",
  "scripts": {
    "test": "karma start ClientApp/test/karma.conf.js"
  },
  "dependencies": {
    "@angular/common": "^2.4.5",
    "@angular/compiler": "^2.4.5",
    "@angular/core": "^2.4.5",
    "@angular/forms": "^2.4.5",
    "@angular/http": "^2.4.5",
    "@angular/platform-browser": "^2.4.5",
    "@angular/platform-browser-dynamic": "^2.4.5",
    "@angular/platform-server": "^2.4.5",
    "@angular/router": "^3.4.5",
    "@types/node": "^6.0.42",
    "@types/jquery": "2.2.1" ,
    "angular2-platform-node": "~2.0.11",
    "angular2-template-loader": "^0.6.2",
    "angular2-universal": "^2.1.0-rc.1",
    "angular2-universal-patch": "^0.2.1",
    "angular2-universal-polyfills": "^2.1.0-rc.1",
    "aspnet-prerendering": "^2.0.0",
    "aspnet-webpack": "^1.0.17",
    "awesome-typescript-loader": "^3.0.0",
    "bootstrap": "^3.3.7",
    "css": "^2.2.1",
    "css-loader": "^0.25.0",
    "es6-shim": "^0.35.1",
    "event-source-polyfill": "^0.0.7",
    "expose-loader": "^0.7.1",
    "extract-text-webpack-plugin": "^2.0.0-rc",
    "file-loader": "^0.9.0",
    "html-loader": "^0.4.4",
    "isomorphic-fetch": "^2.2.1",
    "jquery": "^2.2.1",
    "json-loader": "^0.5.4",
    "preboot": "^4.5.2",
    "raw-loader": "^0.5.1",
    "rxjs": "^5.0.1",
    "style-loader": "^0.13.1",
    "to-string-loader": "^1.1.5",
    "typescript": "^2.2.1",
    "url-loader": "^0.5.7",
    "webpack": "^2.2.0",
    "webpack-hot-middleware": "^2.12.2",
    "webpack-merge": "^0.14.1",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@types/chai": "^3.4.34",
    "@types/jasmine": "^2.5.37",
    "chai": "^3.5.0",
    "jasmine-core": "^2.5.2",
    "karma": "^1.3.0",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-webpack": "^1.8.0"
  }
}

可能出了什么问题?

编辑

我尝试按照 Adrian Hall 的建议指定节点的版本,但这并没有解决问题:

npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! code ETARGET

npm ERR! notarget No compatible version found: @types/jquery@2.2.1
npm ERR! notarget Valid install targets:
npm ERR! notarget 2.0.41, 2.0.40, 2.0.39, 2.0.38, 2.0.37, 2.0.36, 2.0.35, 2.0.34, 2.0.33, 2.0.32, 1.10.31, 1.10.30, 1.10.29, 1.10.28, 1.10.27, 1.10.26-alpha, 1.10.25-alpha, 1.10.24-alpha, 1.10.23-alpha, 1.10.22-alpha, 1.10.21-alpha, 1.10.20-alpha, 1.10.15-alpha, 1.10.14-alpha, 1.10.8-alpha
npm ERR! notarget 
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget 
npm ERR! notarget It was specified as a dependency of 'AstroWeb'
npm ERR! notarget 

我尝试在 packages.json 中设置版本 2.0.41,我不再遇到同样的问题,只是我的 import 'jquery' 之一现在失败了。

我还设法运行(https://my-site.scm.azurewebsites.net/DebugConsolenpm install -g npm,这似乎升级了远程 NPM 版本(到 4.5.0),现在似乎已经解决了这个问题

【问题讨论】:

    标签: jquery azure npm asp.net-core


    【解决方案1】:

    您的 node.js 版本(可能还有 npm 版本)可能与 Azure 应用服务上使用的默认版本不同。使用 package.json 的“engines”部分在 node 和 npm 上指定正确的版本。请参阅我的博客文章,其中提到了这一点:https://shellmonger.com/2015/08/29/continuous-deployment-nodejs-and-microsoft-azure/

    【讨论】:

    • 我应该指定哪个引擎版本?
    • 我尝试指定与我的相同(>=3.10.10),但我仍然遇到同样的问题。但是 NPM 是在抱怨 jquery,不是吗?
    • 另外,我的版本是我刚刚发布的发布脚本上显示的版本,所以你的意思是我应该将我的本地版本改为远程使用的版本?因为我尝试将 npm+node 版本设置为我在本地或远程设置的版本,并且我遇到了同样的问题
    • 您提到将远程 NPM 升级到 4.5.0 解决了这个问题。这表明您的本地开发环境使用的 node/npm 包组合比远程 node/npm 包组合更新。您在 package.json 中使用“engines”设置远程节点/npm 包组合。如果您的本地环境有效而远程环境不有效,则应将其设置为与您的本地环境匹配。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-18
    • 2017-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-15
    • 1970-01-01
    相关资源
    最近更新 更多