Laravel-mix: Cannot find module: cross-env.js

Created on 4 Mar 2017  路  3Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 0.8.3;
  • Node Version: v7.6.0;
  • NPM Version: v4.1.2
  • OS: macOS Sierra

Description:
When running npm run dev or yarn run dev (tried with both using fresh installs) get the following error below. Tried a bunch of stuff including:

  • Going back to version 0.8.1 and 0.8.3, same error is present
  • Went through a bunch of the issues which people have previously submit and had no luck.

Error: Cannot find module '{{Location to Project}}/node_modules/cross-env/bin/cross-env.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Most helpful comment

cross-env must have updated its paths, it has "cross-env/dist/bin" not "cross-env/bin/"

in package.json
(EDIT)

"dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"

All 3 comments

I had the same problem. The error says it can't find the module "node_modules/cross-env/bin/cross-env.js". If you check the directory is actually "node_modules/cross-env/dist/bin/cross-env.js". What you can do is change that directory on the scripts on package.json. Or another thing that worked for me was to change "node node_modules/cross-env/bin/cross-env.js" on the scripts for simply "cross-env" just like @JeffreyWay does it in this repo.

cross-env must have updated its paths, it has "cross-env/dist/bin" not "cross-env/bin/"

in package.json
(EDIT)

"dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"

Thanks its works

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Cheddam picture Cheddam  路  3Comments

Bomavi picture Bomavi  路  3Comments

tillkruss picture tillkruss  路  3Comments

RomainGoncalves picture RomainGoncalves  路  3Comments

pixieaka picture pixieaka  路  3Comments