部署期间发现NPM Invalid Package @types

时间:2017-11-14 23:37:33

标签: reactjs azure typescript npm continuous-deployment

我正在尝试使用azure的持续开发运行我的第一个应用程序,这是来自Visual Studio 2017 MVC net core 2.0的标准模板的应用程序,使用React。我只是将这个应用程序推送到我的github,在配置了azure到自动部署的分支上,并且部署日志我可以看到:

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment.
  Restore completed in 680.87 ms for D:\home\site\repository\PortfolioKJ\PortfolioKJ.csproj.
  Restore completed in 1.08 sec for D:\home\site\repository\PortfolioKJ\PortfolioKJ.csproj.
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  PortfolioKJ -> D:\home\site\repository\PortfolioKJ\bin\Release\netcoreapp2.0\PortfolioKJ.dll
EXEC : npm ERR! error : Invalid Package: expected types/react-hot-loader but found @types/react-hot-loader [D:\home\site\repository\PortfolioKJ\PortfolioKJ.csproj]
  npm ERR!     at D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-local-tarball.js:161:14
  npm ERR!     at process._tickCallback (node.js:448:13)
  npm ERR! If you need help, you may report this *entire* log,
  npm ERR! including the npm and node versions, at:
  npm ERR!     <http://github.com/npm/npm/issues>

  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "node" "D:\\Program Files (x86)\\npm\\1.4.28\\node_modules\\npm\\bin\\npm-cli.js" "install"
  npm ERR! cwd D:\home\site\repository\PortfolioKJ
  npm ERR! node -v v0.10.40
  npm ERR! npm -v 1.4.28
  npm
D:\home\site\repository\PortfolioKJ\PortfolioKJ.csproj(39,5): error MSB3073: The command "npm install" exited with code 1.
Failed exitCode=1, command=dotnet publish "D:\home\site\repository\PortfolioKJ\PortfolioKJ.csproj" --output "D:\local\Temp\8d52bb32bb3bc7e" --configuration Release
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu\67.61109.3117\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"

我真的不知道我现在能做什么。我希望如果一切都是标准的,它可以毫无问题地运行。

这是tsconfig.json

{
  "compilerOptions": {
    "baseUrl": ".",
    "module": "es2015",
    "moduleResolution": "node",
    "target": "es5",
    "jsx": "react",
    "experimentalDecorators": true,
    "sourceMap": true,
    "skipDefaultLibCheck": true,
    "strict": true,
    "lib": ["es6", "dom"],
    "types": ["webpack-env"]
  },
  "exclude": [
      "bin",
      "node_modules"
  ]
}

在我的本地电脑上一切都很棒。

2 个答案:

答案 0 :(得分:2)

Missed line

我发现了我的问题。问题是在天蓝色服务器上的行npm ERR! node -v v0.10.40,节点的默认版本是0.10,这无法解决@types的含义。要解决此问题,我必须在Azure上的应用程序设置中添加行WEBSITE_NODE_DEFAULT_VERSION和值4.2.3

答案 1 :(得分:0)

关注错误信息:

  

无效的包:期望的类型/ react-hot-loader但找到@ types / react-hot-loader

如果某些match中提及types/react-hot-loader,则会发生这种情况。

修复

确保对package.json的所有引用均以types为前缀,即@。对于简单的JavaScript / TypeScript项目,明显要检查的地方是@types

更多

由于您使用的是ASP.Net构建工具,因此您可能需要使用msbuild / proj文件。如果没有,模板或azure自动部署代码中可能存在错误。