Cloud Functions deploy error during lint on Window

2019-01-04 13:35发布

Following the firebase function getting started guide and getting a seemingly simple error once trying to deploy with:

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

The package.json file does exist just as the tutorial shows in my project/functions/package.json. Have tried changing or printing out the RESOURCE_DIR env with no success. Assuming it would be scoped inside of the NPM shell environment.

npm version: 5.6.0

node version: 8.9.0

9条回答
女痞
2楼-- · 2019-01-04 14:05

As an extra doing npm --prefix %RESOURCE_DIR% run lint like @Deji James said, made me some progress but still didn't work.

As a suggestion I found this https://github.com/firebase/firebase-tools/issues/610

and @merlinnot says here Hey guys, you all probably have sth in your predeploy in firebase.json, don't you? Just delete what you have there for now if it's not that important.

worked for me. PS. before deciding to delete, I have done all reinstall things, uninstall things. Only this is worked.

查看更多
男人必须洒脱
3楼-- · 2019-01-04 14:06

You can fix this by accessing your firebase.json file and delete this line containing RESOURCE_DIR.

查看更多
Melony?
4楼-- · 2019-01-04 14:08

Apart from the other suggestions, if you change the preflight/predeploy command from:

"npm --prefix \"$RESOURCE_DIR\" run lint", OR
"npm --prefix \"%RESOURCE_DIR%\" run lint"

to

"npm --prefix ./functions run lint"

the issue seems to get fixed. This also resolves it for both Windows and Linux.

To see more details, please see this answer (and further thread): https://github.com/firebase/firebase-tools/issues/610#issuecomment-360147507

查看更多
Luminary・发光体
5楼-- · 2019-01-04 14:09

In windows, while Initializing the firebase Project in CLI using firebase init,In firebase.json file,Change the code to as per below{ "functions": { "predeploy": [ "npm --prefix \"%RESOURCE_DIR%\" run lint" ], "source": "functions" } } After this change, try firebase deploy --only functions command.

查看更多
时光不老,我们不散
6楼-- · 2019-01-04 14:15

When running

firebase init functions

I use this configuration

? What language would you like to use to write Cloud Functions? JavaScript
//TypeScript doesn't work
? Do you want to use ESLint to catch probable bugs and enforce style? Yes
//If you don't you will get a missing file lint
? File functions/package.json already exists. Overwrite? Yes
? Do you want to install dependencies with npm now? Yes
//Why not

Then if use windows

Replace $RESOURCE_DIR by %RESOURCE_DIR% in firebase.json

查看更多
孤傲高冷的网名
7楼-- · 2019-01-04 14:16

You have to change firebase.json file as shown in here

"npm --prefix functions run lint"
"npm --prefix functions run build"
查看更多
登录 后发表回答