问题描述
也许这是不具体涉及到的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 \\..
?
吉斯特
如何重现:
- 克隆
https://github.com/intellismiths/webapp1
库。 - 创建新的Azure的Web应用程序(默认设置)。
- 配置部署源使用GitHub上。
- 点击
同步
。这将需要超过10分钟即可完成,它会显示在部署成功。 - 转到应用程序设置在Azure和修改
WEBSITE_NODE_DEFAULT_VERSION
到6.2.2
- 转到页捻和开放的PowerShell控制台。
- 执行
NPM缓存清理
- 执行
节点-v
检查节点版本。它应该是V6.2.2
- 在Azure中,导航到
D:\\家\\网站\\程序存储库的\\ src \\ WebApp1
- 执行
NPM运行构建
- 在控制台中,您会看到很多的错误表明模块不能被解析
- 可选。测试
NPM运行构建
在本地机器上 - 它应该产生wwwroot文件/ app.js
没有错误 - 更新
webpack.config.js
包括背景:__dirname
来修复previous错误 - 执行
NPM运行构建
- 在控制台中,您应该看到的RangeError:最大调用堆栈大小超过了。错误
- Clone the
https://github.com/intellismiths/webapp1
repository. - Create new Azure Web App (default settings).
- Configure deployment source to use GitHub.
- Click
Sync
. It will take 10+ minutes to complete and it will show that the deployment was successful. - Go to Application settings in Azure and change
WEBSITE_NODE_DEFAULT_VERSION
to6.2.2
- Go to kudu page and open powershell console.
- Execute
npm cache clean
- Check node version by executing
node -v
. It should bev6.2.2
- On Azure, navigate to
D:\home\site\respository\src\WebApp1
- Execute
npm run build
- In console, you should see a lot of errors which indicates that modules can not be resolved.
- OPTIONAL. Test
npm run build
on your local machine - it should producewwwroot/app.js
without errors. - Update
webpack.config.js
to includecontext: __dirname
to fix previous errors. - Execute
npm run build
- 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!