Skip to content

Commit af43adc

Browse files
oroceSaraVieira
authored andcommitted
Do not silently ignore package.json in zeit deployment (codesandbox#1540)
If you omit the `files` entry in your `now.json` then the deployment works without any issues but if you customize the `now.files` and you happen to have `package.json` in that list, it will be ignored from the deployment. If the package.json is omitted then zeit won't install the required dependencies. Example configuration: now.json ``` { "version": 2, "files": [ "index.js", "package.json" ], "builds": [{ "src": "index.js", "use": "@now/node" }] } ``` package.json ``` { "dependencies": { "express": "4.16.4" } } ``` index.js ``` require('express'); ``` The deployment of a sandbox with the configuration above will be successful but when you are trying to open your deployment it'll crash with an error of 500. (`MODULE_NOT_FOUND`) I found this issue while I was building a Pusher authentication server using zeit for a [sample vue chat app](https://codesandbox.io/s/9z1prn05pr). I had to define the `now.files` since the sandbox has lots of files (config, static, build, etc) which should be deployed to zeit (and cannot be due to some zeit errors). For now, I moved the server to a different sandbox and deployed from [there](https://codesandbox.io/s/j4v80y7wzw).
1 parent 4b24193 commit af43adc

File tree

1 file changed

+6
-0
lines changed
  • packages/app/src/app/store/modules/deployment

1 file changed

+6
-0
lines changed

packages/app/src/app/store/modules/deployment/actions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ export async function createApiData({ props, state }) {
9191

9292
apiData.files.push({ file: filePath, data, encoding: 'base64' });
9393
}
94+
if (filePath === 'package.json') {
95+
apiData.files.push({
96+
file: 'package.json',
97+
data: JSON.stringify(packageJSON, null, 2),
98+
});
99+
}
94100
}
95101

96102
// this adds unnecessary code for version 2

0 commit comments

Comments
 (0)