Updating the npm build script

Everything looks good, but if we run the tests, they will return with the following error:

Error: Cannot find module '../../schema/users/profile.json'

This is because Babel, by default, only processes .js files. Therefore, our .json schema files were not processed or copied over to the dist/ directory, which leads to the preceding error. To fix this, we can update our build npm script to use Babel's --copy-files flag, which will copy over any non-compilable files to the dist/ directory:

"build": "rimraf dist && babel src -d dist --copy-files",

Now, if we run our tests again, they should all pass.

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.