Skip to content

package-lock.json causes "react-scripts: not found" when deploying #9

Closed
@joshboyan

Description

@joshboyan

I am having a difficult time getting this deployed once I add some more code to the repo.

It works just as expected locally with the npm run start and npm run build commands.

I have been searching stack overflow and haven't found anything. I have even tried to add react-scripts to the Dependencies as well but am still getting this print out when I deploy.

($ git push heroku master
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 639 bytes | 0 bytes/s, done.
Total 7 (delta 4), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  6.9.x
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 6.9.x via semver.io...
remote:        Downloading and installing node 6.9.5...
remote:        Detected package-lock.json: defaulting npm to version 5.x.x
remote:        Resolving npm version 5.x.x via semver.io...
remote:        Downloading and installing npm 5.0.4 (replacing version 3.10.10).
..
remote:
remote: -----> Restoring cache
remote:        Loading 2 from cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (not cached - skipping)
remote:
remote: -----> Building dependencies
remote:        Installing node modules (package.json)
remote:        removed 1185 packages in 18.503s
remote:        Running heroku-postbuild
remote:
remote:        > heroku-cra-node@1.0.0 heroku-postbuild /tmp/build_cf752754736fe
7ea551ef5c015e7debe
remote:        > cd react-ui/ && npm install --only=dev && npm install && npm ru
n build
remote:
remote:        added 1069 packages in 31.462s
remote:        removed 1069 packages in 22.593s
remote:
remote:        > appointment-ledger-map@0.1.0 build /tmp/build_cf752754736fe7ea5
51ef5c015e7debe/react-ui
remote:        > react-scripts build
remote:
remote: sh: 1: react-scripts: not found
remote: npm ERR! file sh
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno ENOENT
remote: npm ERR! syscall spawn
remote: npm ERR! appointment-ledger-map@0.1.0 build: `react-scripts build`
remote: npm ERR! spawn ENOENT
remote: npm ERR!
remote: npm ERR! Failed at the appointment-ledger-map@0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additi
onal logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /app/.npm/_logs/2017-07-01T00_08_13_208Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! heroku-cra-node@1.0.0 heroku-postbuild: `cd react-ui/ && npm in
stall --only=dev && npm install && npm run build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the heroku-cra-node@1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additi
onal logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /app/.npm/_logs/2017-07-01T00_08_13_224Z-debug.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common is
sues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploy
s
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to immense-escarpment-58375.
remote:
To https://git.heroku.com/immense-escarpment-58375.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/immense-escarpment-58
375.git')

I found that if I set NPM_CONFIG_PRODUCTION=false it compiles without any errors and deploys but I just get a 503 error when I check the site.

Also, while troubleshooting this I ran the heroku post-build hook cd react-ui/ && npm install --only=dev && npm install && npm run build locally from the parent directory and got this message.

Creating an optimized production build...
Failed to compile.

Module not found: Error: Can't resolve 'react' in 'C:\Users\Josh\Desktop\project
s\heroku-appt\react-ui\src'

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! appointment-ledger-map@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the appointment-ledger-map@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Josh\AppData\Roaming\npm-cache\_logs\2017-07-01T00_11_29_2
95Z-debug.log

If the rest of the source would help you can see it here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions