Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js azure部署:站点/wwwroot中没有package.json文件_Node.js_Azure - Fatal编程技术网

Node.js azure部署:站点/wwwroot中没有package.json文件

Node.js azure部署:站点/wwwroot中没有package.json文件,node.js,azure,Node.js,Azure,当我尝试在Chrome中打开我的Azure NodeJS React web应用程序时,出现以下错误: PATH="$PATH:/home/site/wwwroot" npm start ENOENT: no such file or directory, open '/home/site/wwwroot/package.json 当我在Azure SSH中检查/site/wwwroot的内容时,就会发现这一点: _del_node_modules asset-manifest.json b

当我尝试在Chrome中打开我的Azure NodeJS React web应用程序时,出现以下错误:

PATH="$PATH:/home/site/wwwroot" npm start
ENOENT: no such file or directory, open '/home/site/wwwroot/package.json
当我在Azure SSH中检查/site/wwwroot的内容时,就会发现这一点:

_del_node_modules
asset-manifest.json
b
favicon.ico
index.html
logo192.png
logo512.png
manifest.json
oryx-appinsightsloader.js
package-lock.json
precache-manifest.6794c2e4defba13a31dcee7cae67859b.js
precache-manifest.705c77ad34ded94d21baca064fa569aa.js
precache-manifest.730dd540546e78da1c3ebb04036e733d.js
precache-manifest.9980bb9186e0ebd2771eff926887f432.js
precache-manifest.9a518a34a27fad9a357b7c78cdfbb7e8.js
precache-manifest.9c65ce33aab3813a0f162cf91b74c0f4.js
precache-manifest.ac183c8385a56a732a8286d5f2d8fa64.js
precache-manifest.b8756a719b957537ff5eb2ede103962d.js
precache-manifest.cbb7b5b3cc0bfbf94c161143ff651d3b.js
precache-manifest.e58827ccfca6115bc9268d09a7361ddd.js
robots.txt
service-worker.js
static
web.config
Azure上的我的构建管道从根目录运行npm安装和npm运行构建,在VScode中运行时会成功。管道和释放是成功的。VScode中我的目录树的外部结构如下所示:

├── README.md
├── node_modules
├── package-lock.json
├── package.json
├── public
├── schema.sql
├── server
└── src
因此,
npm run build
似乎正在成功运行,创建了一个
build
文件夹来填充
/site/wwwroot
文件夹。但是Azure需要一个
package.json
文件。我尝试在VScode中的
public
文件夹中运行
npm init
,并尝试将
npm init
添加到Azure管道构建任务中,但得到了相同的错误

另外,不确定这是否相关,但我在
public
文件夹中添加了一个
web.config
文件。当我在Azure SSH中查看该文件时,它似乎无法正确读取:

/home/site/wwwroot/web.config: line 1: !--: No such file or directory
/home/site/wwwroot/web.config: line 2: $'\r': command not found
/home/site/wwwroot/web.config: line 3: ?xml: No such file or directory
/home/site/wwwroot/web.config: line 4: configuration: No such file or directory
/home/site/wwwroot/web.config: line 5: system.webServer: No such file or directory
/home/site/wwwroot/web.config: line 6: handlers: No such file or directory
/home/site/wwwroot/web.config: line 7: add: No such file or directory
/home/site/wwwroot/web.config: line 8: /handlers: No such file or directory
/home/site/wwwroot/web.config: line 9: rewrite: No such file or directory
/home/site/wwwroot/web.config: line 10: rules: No such file or directory
/home/site/wwwroot/web.config: line 11: rule: No such file or directory
/home/site/wwwroot/web.config: line 12: match: No such file or directory
/home/site/wwwroot/web.config: line 13: action: No such file or directory
/home/site/wwwroot/web.config: line 14: /rule: No such file or directory
/home/site/wwwroot/web.config: line 15: rule: No such file or directory
/home/site/wwwroot/web.config: line 16: match: No such file or directory
/home/site/wwwroot/web.config: line 17: conditions: No such file or directory
/home/site/wwwroot/web.config: line 18: add: No such file or directory
/home/site/wwwroot/web.config: line 19: add: No such file or directory
/home/site/wwwroot/web.config: line 20: add: No such file or directory
/home/site/wwwroot/web.config: line 21: /conditions: No such file or directory
/home/site/wwwroot/web.config: line 22: action: No such file or directory
/home/site/wwwroot/web.config: line 23: /rule: No such file or directory
/home/site/wwwroot/web.config: line 24: /rules: No such file or directory
/home/site/wwwroot/web.config: line 25: /rewrite: No such file or directory
/home/site/wwwroot/web.config: line 26: /system.webServer: No such file or directory
/home/site/wwwroot/web.config: line 27: syntax error near unexpected token `newline'
/home/site/wwwroot/web.config: line 27: `</configuration>'
/home/site/wwwroot/web.config:第1行:!--:没有这样的文件或目录
/home/site/wwwroot/web.config:第2行:$'\r':未找到命令
/home/site/wwwroot/web.config:第3行:?xml:没有这样的文件或目录
/home/site/wwwroot/web.config:第4行:配置:没有这样的文件或目录
/home/site/wwwroot/web.config:第5行:system.webServer:没有这样的文件或目录
/home/site/wwwroot/web.config:第6行:处理程序:没有这样的文件或目录
/home/site/wwwroot/web.config:第7行:添加:没有这样的文件或目录
/home/site/wwwroot/web.config:第8行:/handlers:没有这样的文件或目录
/home/site/wwwroot/web.config:第9行:重写:没有这样的文件或目录
/home/site/wwwroot/web.config:第10行:规则:没有这样的文件或目录
/home/site/wwwroot/web.config:第11行:规则:没有这样的文件或目录
/home/site/wwwroot/web.config:第12行:匹配:没有这样的文件或目录
/home/site/wwwroot/web.config:第13行:操作:没有这样的文件或目录
/home/site/wwwroot/web.config:line 14:/rule:没有这样的文件或目录
/home/site/wwwroot/web.config:第15行:规则:没有这样的文件或目录
/home/site/wwwroot/web.config:第16行:匹配:没有这样的文件或目录
/home/site/wwwroot/web.config:第17行:条件:没有这样的文件或目录
/home/site/wwwroot/web.config:第18行:添加:没有这样的文件或目录
/home/site/wwwroot/web.config:第19行:添加:没有这样的文件或目录
/home/site/wwwroot/web.config:第20行:添加:没有这样的文件或目录
/home/site/wwwroot/web.config:line 21:/conditions:没有这样的文件或目录
/home/site/wwwroot/web.config:第22行:操作:没有这样的文件或目录
/home/site/wwwroot/web.config:line 23:/rule:没有这样的文件或目录
/home/site/wwwroot/web.config:line 24:/rules:没有这样的文件或目录
/home/site/wwwroot/web.config:line 25:/rewrite:没有这样的文件或目录
/home/site/wwwroot/web.config:line 26:/system.webServer:没有这样的文件或目录
/home/site/wwwroot/web.config:第27行:意外标记“newline”附近出现语法错误
/home/site/wwwroot/web.config:第27行:`'
以下是它在VScode中的外观:

<!-- tells azure to rewrite all urls as if they are pointing to root file-->

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
        </handlers>
        <rewrite>
            <rules>
                <rule name="DynamicContent">
                    <match url="/*" />
                    <action type="Rewrite" url="index.js"/>
                </rule>
                <rule name="React Routes" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

更新:

转到
https://[yourappname].scm.azurewebsites.net/websh/host
并运行
npm安装-g npm
,然后在
home/site/wwwroot
下运行
npm init
命令

原始答案:

您是否选择Linux作为Web应用程序的操作系统?我在linux上遇到了类似的问题,但在Windows操作系统上没有


理论上,没有
package.json
,只需使用
npminit
来创建它。我可以在Windows操作系统上顺利操作,但在Linux上不行。我正在调查。

更新:

转到
https://[yourappname].scm.azurewebsites.net/websh/host
并运行
npm安装-g npm
,然后在
home/site/wwwroot
下运行
npm init
命令

原始答案:

您是否选择Linux作为Web应用程序的操作系统?我在linux上遇到了类似的问题,但在Windows操作系统上没有


理论上,没有
package.json
,只需使用
npminit
来创建它。我可以在Windows操作系统上顺利操作,但在Linux上不行。我正在调查。

我也遇到了这个问题(使用windows)。很难创建
包.json
——因为它没有出现在
npm init
之后。阻止我安装npm软件包

它帮助我:

type NUL > package.json
获取实际有效的package.json


在Azure门户中创建函数应用时遇到了我的问题

我也遇到了这个问题(使用windows)。很难创建
包.json
——因为它没有出现在
npm init
之后。阻止我安装npm软件包

它帮助我:

type NUL > package.json
获取实际有效的package.json


在Azure门户中创建函数应用程序时遇到我的问题

谢谢。我正在使用Linux。在Windows上启动应用程序服务时遇到一些问题。我会听从你最新的建议。PS我是你回答这个问题的另一个线程中的同一个人,我相信这个问题的格式更好,所以我将删除另一个问题。以下是你从另一个线程中为后代提供的答案:
你能提供home/site/wwwroot中的文件夹和文件吗?看来你没有