简体   繁体   English

部署期间发现NPM无效软件包@types

[英]NPM Invalid Package during deployment found @types

I'm trying to run my first application with azure's continuous development, this is app from standard template from Visual Studio 2017 MVC net core 2.0, using React. 我正在尝试使用Azure的持续开发来运行我的第一个应用程序,这是使用React从Visual Studio 2017 MVC网络核心2.0的标准模板中提取的应用程序。 I just pushed this app to my github, on branch configured with azure to auto deploy, and deploy log i can see this: 我只是将此应用程序推送到我的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"

I realy don't know what i can do now. 我真的不知道我现在能做什么。 I was hoping that if everything is standard, it could run without issues. 我希望如果一切都是标准的,那么它可以毫无问题地运行。

Here is tsconfig.json 这是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"
  ]
}

On my local PC everything works great. 在我的本地PC上,一切正常。

错过线

I found my issue. 我发现了我的问题。 Problem was with line npm ERR! node -v v0.10.40 问题出在行npm ERR! node -v v0.10.40 npm ERR! node -v v0.10.40 , default version of node, on azure server was 0.10, which couldn't resolve what @types mean. 在azure服务器上, npm ERR! node -v v0.10.40 (默认的节点版本)为0.10,无法解析@types的含义。 To solve this, I had to add line WEBSITE_NODE_DEFAULT_VERSION , and value 4.2.3 , to my Application's settings on Azure. 为了解决这个问题,我必须在我在Azure上的应用程序设置中添加WEBSITE_NODE_DEFAULT_VERSION行,并将值4.2.3添加到应用程序中。

Focus in on the error message: 关注错误消息:

Invalid Package: expected types/react-hot-loader but found @types/react-hot-loader 无效的软件包:预期的类型/反应热加载器,但发现@ types /反应热加载器

This will happen if you have types/react-hot-loader was mentioned in some package.json . 如果您在某些package.json中提到了types/react-hot-loader ,则会发生这种情况。

Fix 固定

Make sure all references to types are prefixed with @ ie @types . 确保所有对types引用都以@@types为前缀。 Obvious place to check is package.json for simple JavaScript / TypeScript projects 对于简单的JavaScript / TypeScript项目,显而易见的检查位置是package.json

More 更多

Since you are using ASP.Net build tooling you might need to fiddle with msbuild / proj files. 由于您使用的是ASP.Net构建工具,因此您可能需要摆弄msbuild / proj文件。 If not, there might be a bug in the template or azure auto deploy code. 如果不是,则模板中可能存在错误或azure自动部署代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM