question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cross-env not found

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
iphilgoodcommented, Aug 29, 2016

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.

2reactions
karudocommented, Jun 23, 2016

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel Mix "sh: 1: cross-env: not found error" - Stack Overflow
First check if cross-env module is installed. If not, run: npm install cross-env. After that you need to go to the node_modules folder....
Read more >
cross-env: command not found error [Solved] | bobbyhadz
Use npx to solve the error "cross-env: command not found", e.g. npx cross-env NODE_ENV=production webpack --config build/webpack.config.js or install the ...
Read more >
How to resolve npm command not found: cross-env error
How to resolve npm command not found: cross-env error · Open the terminal in your project directory, then use npm install command to...
Read more >
cross-env not found on npm run dev - Laracasts
You need to check if that path exists in your node_modules folder (path of the cross-env library). At times it's located within the...
Read more >
cross-env: command not found · Issue #493 · react-boilerplate ...
I'm running node 4.4.5 locally. Cloned the repo, ran setup command without issue. On 'npm run start' I get an error: react-boilerplate@3.0.0 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found