I am trying to compile webpack configuration files with Laravel Mix.
Following webpack episode on Laracasts Vue 2 series,
// Scripts
"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"
},
....
// mix
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.version();
When I run $ npm run dev, I get an error:
npm ERR! Exit status 1
npm ERR! Failed at the # dev script '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'.
// Running
npm ERR! node v4.4.5
npm ERR! npm v2.15.5
// The error points to
let extractPlugin = new plugins.ExtractTextPlugin(
/Users/User/Code/project/node_modules/laravel-mix/setup/webpack.config.js:126
The issue seems to be update a Node.js dependency: https://github.com/JeffreyWay/laravel-mix/issues/264
How do I update the Node.js dependency?
I am trying:
$ brew upgrade node : Error = node not installed
$ node -v = 2.15.5
$ npm -v = 4.4.5
$ brew install node // installs but throws error
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
brew link --overwrite node
To list all files that would be deleted:
brew link --overwrite --dry-run node
Possible conflicting files are:
/usr/local/bin/node
...
**$ brew upgrade node // says node 7.5.0 already installed**
$ npm run dev // same error
$ node -v = 4.4.5
I also ran $ brew install node which installed, but I got an error:
Error: The brew link step did not complete successfully.
The formula built, but is not symlinked into /usr/local.
Could not symlink bin/node.
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
brew link --overwrite node
To list all files that would be deleted:
brew link --overwrite --dry-run node
you can delete your node modules folder in your laravel project.
after that run :
npm install - g npm
this command will reinstall the node modules folder with upgrading node files.
next, you can try and run
npm run dev
and you can also run
npm update
to update your node
hope this answer will help
Im Using Windows 10
You can Download NVM for node it stands for node version manager
after you set it up, type this to your cmd
nvm version
nvm install node {version of node you want}
nvm use {version of node}
hope this works for you
because it works for me
I installed Node.js again from nodejs.org, rewriting old files.
However this actually downgraded npm from 4.4.5 to 4.1.2... Node.js was 2.15.5 and is now 7.5.0.
I also had to install a few modules: $ npm install autoprefixer
$ npm run dev // works now
Related
I have cloned a repo from GitHub for a project. I've already installed node (-v 14.17.5) and npm (-v7.20.6), however when I run npm start I get the following code. I've tried reinstalling node and npm several times but I keep getting the same error:
$ npm start
> simplefolio#1.0.1 start
> webpack server --config webpack.dev.js --open
[webpack-cli] You need to install 'webpack-dev-server' for running 'webpack serve'.
Error: Cannot find module 'webpack-dev-server/bin/cli-flags'
Require stack:
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\#webpack-cli\serve\lib\index.js
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\webpack-cli\lib\webpack-cli.js
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\webpack-cli\lib\bootstrap.js
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\webpack-cli\bin\cli.js
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\webpack\bin\webpack.js
Remove node_modules and package-lock.json, then npm i again
Remove node modules, then npm i again
In my case, I have node 16.13.0 and npm 7.20.1. Removing nodes_modules, package-lock.json and run npm cache clean --force alone didn't help. The key change for me is upgrading npm version to the latest (8.7.0), then combining with clean install.
When I run commands like:
npm run dev
npm run watch
to compile my project. I receive an error that says the laravel-mix directory does not exist.
Error: Cannot find module 'PATH/node_modules/laravel-mix/setup/webpack.config.js'
I have deleted the node_modules directory and used npm install to attempt to get it to install properly and it still is not there. "Laravel-mix" is in the package.json file as a dependency, so to my knowledge running npm install or npm install laravel-mix should do the trick, but it isn't working. Any information about this would be greatly appreciated.
npm -v 6.14.1
node -v 12.16.2
Have you already run the following?
npm install laravel-mix
npm install cross-env
im triying to install jhipster but I can't install
npm install -g yo
im getting this
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
✖ yo version
Your yo version is outdated.
Upgrade to the latest version by running:
npm install -g yo#latest
Found potential issues on your machine :(
+ yo#2.0.5
but if I run
npm install yo
im not getting any problem
im using
npm -v
6.4.1
node -v
v10.13.0
and macOS Mojave 10.14
I try a different way I run
yarn global add yo
then
export PATH="$PATH:$(yarn global bin):$HOME/.config/yarn/global/node_modules/.bin"
and
yo jhipster
now jhipster is finally working 😀
On the Mac, after installing node with:
brew install node
The only package that showed up in /usr/local/lib/node_modules is npm. My previous installation of node contained a bunch of packages such "express, apn, http2, ws, etc."
Any ideas?
There was not a package.json either.
When you install node you only get npm, those other packages you mention, were installed using
# probably with sudo
npm install -g {package}
The package.json is created when you run:
npm init
It has nothing to do with node installation.
If you wish to start a new project:
mkdir project
cd project
npm init
npm install {package-name} {other-package}
And now you will have a node_modules folder inside project/ and a package.json with {package-name} & {other-package} as dependencies
I'm trying to install Yeoman via npm, but I get the following errors when I run npm install -g yo:
npm WARN deprecated npmconf#2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
/home/marieficid/.node/bin/yo -> /home/marieficid/.node/lib/node_modules/yo/lib/cli.js
> yo#1.6.0 postinstall /home/marieficid/.node/lib/node_modules/yo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✖ Node.js version
Your Node.js version is outdated.
Upgrade to the latest version: https://nodejs.org
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✖ npm version
Your npm version is outdated.
Upgrade to the latest version by running:
npm install -g npm
✔ NODE_PATH matches the npm root
Found potential issues on your machine :(
/home/marieficid/.node/lib
└── yo#1.6.0
Which is very odd because when I run node --version && npm --version I get:
v4.3.1
3.7.3
And when I try to run npm install -g n I get:
/home/marieficid/.node/bin/n -> /home/marieficid/.node/lib/node_modules/n/bin/n
/home/marieficid/.node/lib
└── n#2.1.0
I tried running this solution, which only brought me more issues: Now I can't run node --version, only n --version, which returns 2.1.0, and I can't run npm install -g n because I get this:
marieficid#mariana-K46CB:~$ npm install -g n
/usr/bin/env: node: Arquivo ou diretório não encontrado
Which means "directory not found". What can I do? I'm on Ubuntu 14.04, by the way.
EDIT: I think I screwed up my $PATH variable... does anyone know how to fix it?
You should run
npm install -g npm
not
npm install -g n
according to your output