在 firebase function getting started guide 之后并在尝试部署时遇到一个看似简单的错误:
firebase deploy --only functions
i deploying functions
Running command: npm --prefix $RESOURCE_DIR run lint
npm ERR! path C:\Users\Beat\leginformant\$RESOURCE_DIR\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open
'C:\Users\Beat\leginformant\$RESOURCE_DIR\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
package.json 文件确实存在,就像教程在我的项目/functions/package.json 中显示的那样。 已尝试更改或打印出 RESOURCE_DIR 环境,但没有成功。假设它会在 NPM shell 环境中限定范围。
npm 版本:5.6.0
节点版本:8.9.0
最佳答案
这是 Firebase CLI 3.17.0 至至少 3.17.3 的一个已知问题,但仅限于 Windows。您可以通过编辑项目根目录下的 firebase.json
并在 npm 中将 $RESOURCE_DIR
替换为 %RESOURCE_DIR%
来在您的计算机上修复此问题你在那里看到的命令。前者是使用环境变量的 unix 语法方式,而后者是 Windows 命令 shell 语法。由于您使用的是 Windows,因此需要使用 Windows 语法。
该团队正在研究避免必须更改您使用的配置文件的方法,因为对于跨平台工作的团队来回更改同一文件并不是很方便。
编辑:这个问题应该在使用 CLI 版本 3.17.5 创建的项目中得到解决。
关于windows - Cloud Functions 在 Windows : "enoent ENOENT: no such file or directory" 上的 lint 期间部署错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48370690/