错误:尝试运行node.js应用程序时找不到模块'asn1'

时间:2017-09-11 08:25:47

标签: javascript node.js azure

我正在尝试使用Node 8.1.4在Azure应用服务上运行Node.js应用。

该应用程序在我的本地计算机上正常运行。

我将整个应用程序(包括node_modules)复制到Azure应用服务中,但我明白了:

Mon Sep 11 2017 07:52:14 GMT+0000 (Coordinated Universal Time): Application 
has thrown an uncaught exception and is terminated:
Error: Cannot find module 'asn1'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> 
(D:\home\site\wwwroot\node_modules\sshpk\lib\formats\pem.js:9:12)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)

这来自一个名为sshpk的软件包。以下是它的依赖关系:

"dependencies": {
    "asn1": "~0.2.3",
    "assert-plus": "^1.0.0",
    "bcrypt-pbkdf": "^1.0.0",
    "dashdash": "^1.12.0",
    "ecc-jsbn": "~0.1.1",
    "getpass": "^0.1.1",
    "jsbn": "~0.1.0",
    "tweetnacl": "~0.14.0"
  },

我检查过,asn1包肯定位于顶级node_modules文件夹中。我还将asn1包复制到node_modules内的sshpk,但没有帮助。

为什么仍然找不到这个包裹的原因是什么?我该如何解决这个问题?

更新:尝试在Azure服务器上运行npm cache clearnpm install -g npm,没有任何更改。

整个顶级package.json

{
  "name": "my_project",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node --inspect server.js"
  },
  "dependencies": {
    "@google-cloud/datastore": "^1.1.0",
    "asn1": "^0.2.3",
    "async": "^2.1.2",
    "body-parser": "~1.15.2",
    "cookie-parser": "~1.4.3",
    "debug": "~2.2.0",
    "documentdb": "^1.10.0",
    "dotenv": "^4.0.0",
    "express": "~4.14.0",
    "morgan": "~1.7.0",
    "mssql": "^4.0.4",
    "serve-favicon": "~2.3.0"
  }
}

0 个答案:

没有答案