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 doesn't exist anymore? npm webpack scripts fail

See original GitHub issue

I’ve had a problem for a while where npm run dev works on my local machine but in travis-ci it’s blowing up. It did blow up on my machine in the past but I’d poked something and then it worked again. In the process of trying to figure out what was going on, I updated my local machine’s version of laravel-mix and then it broke on this machine too.

I updated laravel-mix and nuked dependencies, the problem persisted. Package.json:

{
  "private": true,
  "scripts": {
    "dev": "node node_modules/cross-env/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/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",
    "hot": "node node_modules/cross-env/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/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"
  },
  "devDependencies": {
    "axios": "^0.15.3",
    "cross-env": "^5.0.1",
    "jquery": "^3.2.1",
    "laravel-mix": "^1.0.7",
    "lodash": "^4.17.4",
    "materialize-css": "^0.98.2",
    "vue": "^2.3.4"
  },
  "dependencies": {}
}

No clue what a .babelrc file is, so I assume I’m not using a custom one.

  • Laravel Mix Version: 1.0.7, but running the command npm list --depth=0 returns more errors than fit in my entire terminal history. Here’s a snippet:
npm ERR! extraneous: is-utf8 /vagrant/node_modules/is-utf8
npm ERR! error in /vagrant/node_modules/is-utf8: Invalid version: "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz"
npm ERR! extraneous: is-valid-glob /vagrant/node_modules/is-valid-glob
npm ERR! error in /vagrant/node_modules/is-valid-glob: Invalid version: "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-0.
3.0.tgz"
npm ERR! extraneous: is-zip /vagrant/node_modules/is-zip
npm ERR! error in /vagrant/node_modules/is-zip: Invalid version: "https://registry.npmjs.org/is-zip/-/is-zip-1.0.0.tgz"
npm ERR! extraneous: isarray /vagrant/node_modules/isarray
npm ERR! error in /vagrant/node_modules/isarray: Invalid version: "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
npm ERR! extraneous: isexe /vagrant/node_modules/isexe
  • Node Version (node -v): v7.5.0
  • NPM Version (npm -v): 5.0.4
  • OS: Vagrant (laravel/homestead (virtualbox, 2.1.0) guest on Windows 10 host. All commands executed in the vagrant box via ssh.

Description:

cross-env appears to not exist anymore once laravel-mix is updated, causing all npm scripts to fail.

vagrant@homestead:/vagrant$ npm run dev

> @ dev /vagrant
> node node_modules/cross-env/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

module.js:472
    throw err;
    ^

Error: Cannot find module '/vagrant/node_modules/cross-env/bin/cross-env.js'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:418:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:533:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `node node_modules/cross-env/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`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-06-27T21_12_12_759Z-debug.log
vagrant@homestead:/vagrant$

Steps To Reproduce:

laravel new test cd test npm run dev

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
ruchernchongcommented, Jun 28, 2017

You have removed cross-env from your scripts but your scripts configuration is wrong.

"scripts": {
    "dev": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "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_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },

This should work for you. You got to remove the node and cross-env.

And if you are using npm v5, you got to delete package-lock.json before running npm install. There is a major issue with npm v5 where it deletes your packages when package-lock.json is present.

1reaction
menashehcommented, Jun 28, 2017

Okay, so that works… In vagrant but not in windows, which I suppose is the entire purpose of cross-env…

Read more comments on GitHub >

github_iconTop Results From Across the Web

cross-env doesn't exist anymore? npm webpack scripts fail #943
Description: cross-env appears to not exist anymore once laravel-mix is updated, causing all npm scripts to fail. vagrant@homestead ...
Read more >
Laravel Mix "sh: 1: cross-env: not found error" - Stack Overflow
The error I am getting when I run any npm run command. > Code@1.0.0 dev /home/vagrant/Code > cross-env NODE_ENV=development webpack --progress ...
Read more >
How to resolve npm command not found: cross-env error
Open the terminal in your project directory, then use npm install command to install the package like this: · If that doesn't work,...
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 >
electron fs not found | The AI Search Engine You Control
To solve the "Cannot find module `fs` or its corresponding type declarations" error, install the types for node by running the command `npm...
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