Azure和节点JS __dirname [英] Azure and node js __dirname

查看:132
本文介绍了Azure和节点JS __dirname的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是不具体涉及到的WebPack /内存-FS,但我得到了的RangeError:最大调用堆栈大小超过错误(请参阅下面的调用堆栈)

Probably it is not specifically related to webpack/memory-fs, but I am getting the RangeError: Maximum call stack size exceeded error (see below for a call stack).

我已经找到了,那 __目录名在Azure上(Web应用程序)的回报<$c$c>\\\\100.78.172.13\\volume-7-default\\8f5ecde749dace2bb57a\\4e07195f015b45ce8e9ba255dc901988\\site\\repository\\Source\\Website\\Content\\app\
ode_modules\\webpack\
ode_modules\\memory-fs\\lib\
ormalize.js在我的情况,而 process.cwd()收益 D:\\家\\网站\\库\\来源\\网站\\内容\\ APP

I have found out, that __dirname on Azure (webapp) returns \\100.78.172.13\volume-7-default\8f5ecde749dace2bb57a\4e07195f015b45ce8e9ba255dc901988\site\repository\Source\Website\Content\app\node_modules\webpack\node_modules\memory-fs\lib\normalize.js in my situation, while process.cwd() returns D:\home\site\repository\Source\Website\Content\app.

时什么都可以从我的身边做配置节点JS返回 D:\\ ... 而不是 \\\\ ..

Is anything can be done from my side to configure node js to return D:\... instead of \\.. ?

<一个href=\"https://gist.githubusercontent.com/zygimantas/6d5fcb15547e84f5773f7b6226734737/raw/f37bd1a1ee46018413aa4cb24fc6187732314838/output.txt\"相对=nofollow>吉斯特

如何重现:


  1. 克隆 https://github.com/intellismiths/webapp1 库。

  2. 创建新的Azure的Web应用程序(默认设置)。

  3. 配置部署源使用GitHub上。

  4. 点击同步。这将需要超过10分钟即可完成,它会显示在部署成功。

  5. 转到应用程序设置在Azure和修改 WEBSITE_NODE_DEFAULT_VERSION 6.2.2

  6. 转到页捻和开放的PowerShell控制台。

  7. 执行 NPM缓存清理

  8. 执行节点-v 检查节点版本。它应该是 V6.2.2

  9. 在Azure中,导航到 D:\\家\\网站\\程序存储库的\\ src \\ WebApp1

  10. 执行 NPM运行构建

  11. 在控制台中,您会看到很多的错误表明模块不能被解析

  12. 可选。测试 NPM运行构建在本地机器上 - 它应该产生 wwwroot文件/ app.js 没有错误

  13. 更新 webpack.config.js 包括背景:__dirname 来修复previous错误

  14. 执行 NPM运行构建

  15. 在控制台中,您应该看到的RangeError:最大调用堆栈大小超过了。错误

  1. Clone the https://github.com/intellismiths/webapp1 repository.
  2. Create new Azure Web App (default settings).
  3. Configure deployment source to use GitHub.
  4. Click Sync. It will take 10+ minutes to complete and it will show that the deployment was successful.
  5. Go to Application settings in Azure and change WEBSITE_NODE_DEFAULT_VERSION to 6.2.2
  6. Go to kudu page and open powershell console.
  7. Execute npm cache clean
  8. Check node version by executing node -v. It should be v6.2.2
  9. On Azure, navigate to D:\home\site\respository\src\WebApp1
  10. Execute npm run build
  11. In console, you should see a lot of errors which indicates that modules can not be resolved.
  12. OPTIONAL. Test npm run build on your local machine - it should produce wwwroot/app.js without errors.
  13. Update webpack.config.js to include context: __dirname to fix previous errors.
  14. Execute npm run build
  15. In console, you should see the "RangeError: Maximum call stack size exceeded" error.

更新1

我只尝试加入第二的package.json后设置6.2.2运行时,这样的项目结构不是简单的可能。也许只是设置节点6.2.2中断构建。

I only tried to set 6.2.2 runtime after adding the second package.json, so the project structure is not the simplest possible. Maybe just setting node to 6.2.2 breaks the build.

推荐答案

我可以复制以下你的脚步您的问题。我找到了关键点被设置 WEBSITE_NODE_DEFAULT_VERSION 6.2.2 。而且我发现的WebPack任务工作得很好,如果 WEBSITE_NODE_DEFAULT_VERSION 正在 6

I could reproduce your issue following your steps. I found the key point was setting the WEBSITE_NODE_DEFAULT_VERSION to 6.2.2. And I found the webpack task worked fine if the WEBSITE_NODE_DEFAULT_VERSION was under 6.

请在降级 6 设置 WEBSITE_NODE_DEFAULT_VERSION 来的版本如 5.9.0 如果你的Node.js的模块不需要这么高的版本。结果
而根据的package.json angular2 athttps的://github.com/angular/angular/blob/master/package.json,似乎angular2库要求节点之间的.js文件版本 5.4 6

Please downgrade the setting WEBSITE_NODE_DEFAULT_VERSION to the version under 6 e.g. 5.9.0 if your node.js modules do not need such high version.
And according the package.json of angular2 athttps://github.com/angular/angular/blob/master/package.json, it seems that the angular2 repository requires the node.js version between 5.4 and 6.

此外,在Azure上Web应用程序的Web应用程序的根目录为 D:\\家\\网站\\ wwwroot文件。所以,如果你想建立在Azure上的Web应用程序的前端的项目,你需要找到以 D:\\家\\网站\\ wwwroot的\\ wwwroot的\\移动web应用程序然后运行 NPM运行构建

Additionally, the web application's root directory on Azure Web Apps is D:\home\site\wwwroot. So if you want to build your frontend project on Azure Web Apps, you need to locate to D:\home\site\wwwroot\wwwroot\mobile-web-app then run npm run build.

这篇关于Azure和节点JS __dirname的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆