Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross-env not found #175

Closed
wdhorton opened this issue Jun 22, 2016 · 11 comments
Closed

cross-env not found #175

wdhorton opened this issue Jun 22, 2016 · 11 comments
Assignees
Labels
bug V2.5.0 React V16.x
Milestone

Comments

@wdhorton
Copy link

I followed the instructions to run docker for development. I ran docker-compose -f docker-compose-development.yml build and it succeeded, but then docker-compose -f docker-compose-development.yml up failed because one of the npm scripts was looking for cross-env and couldn't find it. Here's the trace:

Williams-MacBook-Pro:mern-starter William$ docker-compose -f docker-compose-development.yml up
Starting mernstarter_db_1
Creating mernstarter_web_1
Attaching to mernstarter_db_1, mernstarter_web_1
db_1   | 2016-06-22T17:42:58.921+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=e0f5427f51b1
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten] db version v3.2.7
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten] git version: 4249c1d2b5999ebbf1fdf3bc0e0e3b3ff5c0aaf2
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten] allocator: tcmalloc
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten] modules: none
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten] build environment:
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten]     distmod: debian71
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten]     distarch: x86_64
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten]     target_arch: x86_64
db_1   | 2016-06-22T17:42:58.922+0000 I CONTROL  [initandlisten] options: {}
db_1   | 2016-06-22T17:42:58.926+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
db_1   | 2016-06-22T17:42:58.975+0000 I CONTROL  [initandlisten]
db_1   | 2016-06-22T17:42:58.975+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
db_1   | 2016-06-22T17:42:58.975+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
db_1   | 2016-06-22T17:42:58.975+0000 I CONTROL  [initandlisten]
db_1   | 2016-06-22T17:42:58.975+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
db_1   | 2016-06-22T17:42:58.975+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
db_1   | 2016-06-22T17:42:58.975+0000 I CONTROL  [initandlisten]
db_1   | 2016-06-22T17:42:58.976+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
db_1   | 2016-06-22T17:42:58.976+0000 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
db_1   | 2016-06-22T17:42:58.990+0000 I NETWORK  [initandlisten] waiting for connections on port 27017
web_1  | npm info it worked if it ends with ok
web_1  | npm info using npm@3.9.5
web_1  | npm info using node@v6.2.2
web_1  | npm info lifecycle mern-starter@2.0.0~prestart: mern-starter@2.0.0
web_1  | npm info lifecycle mern-starter@2.0.0~start: mern-starter@2.0.0
web_1  |
web_1  | > mern-starter@2.0.0 start /usr/src/app
web_1  | > cross-env BABEL_DISABLE_CACHE=1 NODE_ENV=development nodemon index.js
web_1  |
web_1  | sh: 1: cross-env: not found
web_1  |
web_1  | npm info lifecycle mern-starter@2.0.0~start: Failed to exec start script
web_1  | npm ERR! Linux 4.4.13-moby
web_1  | npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
web_1  | npm ERR! node v6.2.2
web_1  | npm ERR! npm  v3.9.5
web_1  | npm ERR! file sh
web_1  | npm ERR! code ELIFECYCLE
web_1  | npm ERR! errno ENOENT
web_1  | npm ERR! syscall spawn
web_1  | npm ERR! mern-starter@2.0.0 start: `cross-env BABEL_DISABLE_CACHE=1 NODE_ENV=development nodemon index.js`
web_1  | npm ERR! spawn ENOENT
web_1  | npm ERR!
web_1  | npm ERR! Failed at the mern-starter@2.0.0 start script 'cross-env BABEL_DISABLE_CACHE=1 NODE_ENV=development nodemon index.js'.
web_1  | npm ERR! Make sure you have the latest version of node.js and npm installed.
web_1  | npm ERR! If you do, this is most likely a problem with the mern-starter package,
web_1  | npm ERR! not with npm itself.
web_1  | npm ERR! Tell the author that this fails on your system:
web_1  | npm ERR!     cross-env BABEL_DISABLE_CACHE=1 NODE_ENV=development nodemon index.js
web_1  | npm ERR! You can get information on how to open an issue for this project with:
web_1  | npm ERR!     npm bugs mern-starter
web_1  | npm ERR! Or if that isn't available, you can get their info via:
web_1  | npm ERR!     npm owner ls mern-starter
web_1  | npm ERR! There is likely additional logging output above.
web_1  | npm WARN Local package.json exists, but node_modules missing, did you mean to install?
web_1  |
web_1  | npm ERR! Please include the following file with any support request:
web_1  | npm ERR!     /usr/src/app/npm-debug.log
db_1   | 2016-06-22T17:43:00.260+0000 I NETWORK  [initandlisten] connection accepted from 172.17.0.1:50694 #1 (1 connection now open)
mernstarter_web_1 exited with code 1
@wdhorton
Copy link
Author

I'm running Docker for Mac, Version 1.12.0-rc2-beta16 (build: 9493), in case that's related to the issue.

@somus
Copy link
Contributor

somus commented Jun 23, 2016

NPM install might have failed while building. Could you SSH into the container and try deleting node_modules & run npm install?

@karudo
Copy link

karudo commented Jun 23, 2016

I have same problem.
@somus container can't start, so I can't ssh to container.

@karudo
Copy link

karudo commented Jun 23, 2016

My fix for this problem: https://github.com/karudo/mern-starter/commit/095d3a5e07154d9daa3cdfc9d1f1075fe4b914c9
It is not good, but it's work.

@somus
Copy link
Contributor

somus commented Jun 26, 2016

@kandros any idea why this is happening?

@nkconsulting
Copy link

I have the same problem, I think it has something to do with the mounting of the volume to host source in the docker compose file. When this happens, for some reason I think the node_modules folder is being deleted in the container since the local host folder does not contain them. The build happened on the container not your local host so the folder node_modules does not exist. when you remove the "volumes: - .:/usr/src/app/" command from the docker-compose file, it works but you don't have a mounted volume to work with. I'm still reading up on docker and why this is the case.

@iphilgood
Copy link

I found this post considering the problem we have here.

This is because the mounting of the volume by docker-compose would supercede the
node_modules that was installed in your built image. This causes the volume to
overwrite ontop of the built image.

So what I did was updating the volumes section in the docker-compose.yml.

web:
  build: .
  ...
  volumes:
   - .:/usr/src/app/
   - /usr/src/app/node_modules

After this I've built the container again and everything worked like a charm 🎉.

Initially I thought it was the version of docker-compose, because I had a Ubuntu 16.04 running with version 1.5.0. Locally on my machine I was running with 1.8.0 and didn't encounter the error.

@somus
Copy link
Contributor

somus commented Sep 14, 2016

@wdhorton Have you got a chance to try @iphilgood fix?

@wootsaejao
Copy link
Contributor

Hi there.

The fix from @iphilgood works like a charm.

The thing that annoy me is when mounting the whole directory

  volumes:
     - .:/usr/src/app/

is that there are files produced by Webpack sent back to host machine. So I take an alternative approach.

  volumes:
    - server:/usr/src/app/server
    - client:/usr/src/app/client
    - Intl:/usr/src/app/Intl

Related PR #246

@shankie-codes
Copy link

I'd just like to add that if @iphilgood 's solution above doesn't work for you, it might be worth starting from scratch – remove the container, remove the built image, and then remove dangling volumes. I think I had a dangling volume that still have the cached node_modules. This led to badness.

@mannyhenri mannyhenri self-assigned this Jun 1, 2018
@mannyhenri mannyhenri added this to the 2.5.0 milestone Jun 1, 2018
@mannyhenri mannyhenri added the V2.5.0 React V16.x label Jun 2, 2018
@mannyhenri
Copy link
Contributor

Just merge @wootsaejao PR #246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V2.5.0 React V16.x
Projects
None yet
Development

No branches or pull requests

8 participants