node.js - Elastic Beanstalk 上传和部署错误 : Error: Cannot find module 'semver'

标签 node.js amazon-web-services amazon-elastic-beanstalk

这是我第一次将 Node.js/Express 应用程序上传到 Elastic Beanstalk/AWS。 server 文件夹上传正常。但在另一个环境中,我的 client 文件夹无法加载。

module.js:478
throw err;
^

Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/var/app/current/build/check-versions.js:2:14)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)

我不明白这个错误或原因。有人可以帮忙吗?

它提示重新安装/升级 Node ,但我不相信我可以在AWS上这样做......

完整日志:

-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c8aba4a1ada6bc88f9e6f8e6f8" rel="noreferrer noopener nofollow">[email protected]</a> start script 'node build/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the client package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs client
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls client
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/app/current/npm-debug.log

> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9af9f6f3fff4eedaabb4aab4aa" rel="noreferrer noopener nofollow">[email protected]</a> start /var/app/current
> node build/build.js

module.js:478
    throw err;
    ^

Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/var/app/current/build/check-versions.js:2:14)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)

npm ERR! Linux 4.14.62-65.117.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.14.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.14.3-linux-x64/bin/npm" "start"
npm ERR! node v6.14.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="12717e7b777c6652233c223c22" rel="noreferrer noopener nofollow">[email protected]</a> start: `node build/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b0d3dcd9d5dec4f0819e809e80" rel="noreferrer noopener nofollow">[email protected]</a> start script 'node build/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the client package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs client
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls client
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/app/current/npm-debug.log

> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d7b4bbbeb2b9a397e6f9e7f9e7" rel="noreferrer noopener nofollow">[email protected]</a> start /var/app/current
> node build/build.js

module.js:478
    throw err;
    ^

Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/var/app/current/build/check-versions.js:2:14)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)

npm ERR! Linux 4.14.62-65.117.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.14.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.14.3-linux-x64/bin/npm" "start"
npm ERR! node v6.14.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="284b44414d465c681906180618" rel="noreferrer noopener nofollow">[email protected]</a> start: `node build/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2c4f40454942586c1d021c021c" rel="noreferrer noopener nofollow">[email protected]</a> start script 'node build/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the client package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs client
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls client
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/app/current/npm-debug.log

最佳答案

问题是我自己缺乏对 Node 部署的了解。我试图上传整个客户端文件夹。

我应该做的是运行npm run build来创建一个dist文件(使用长webpack脚本)并将其上传到AWS。在这种情况下,不需要这些依赖项,因为文件是静态提供的。

关于node.js - Elastic Beanstalk 上传和部署错误 : Error: Cannot find module 'semver' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52174628/

相关文章:

node.js - 如何使 Typescript/ts-node 接受后向断言(ECMAScript 2018 功能)?

python - 无法将 WSGI 脚本加载为 Python 模块——500 内部服务器错误

node.js - 将 ElastiCache 连接到 Elastic Beanstalk 实例

security - 我应该如何限制我的 Elastic Beanstalk 环境的负载平衡 Web 流量?

amazon-web-services - 通过 AWS CLI 查找 Beanstalk VPC-ID

javascript - TypeError : this. isModified 不是一个函数 - Mongoose 模型 FindOneAndUpdate

node.js - 带有 NodeJS 的 Mongoose : Default value for document's Date only updates on server restart

node.js - 使用 Node.js 进行 Azure 媒体服务/处理媒体上传和流媒体

amazon-web-services - 由于循环引用,Cloudformation Stack 无法删除

amazon-web-services - Elastic Beanstalk : Application directory/script location on the EC2 Server