I've created a new Laravel-project using composer
./composer.phar create-project laravel/laravel --prefer-dist ProjectName
Next, I've added the required packages through npm. I've already noticed the --save switch is necessary to make it work correctly:
npm install jquery --save
npm install bootstrap --save
npm install font-awesome --save
When I show the packages in this directory:
npm list --depth=0
# /var/www/ProjectName
├── axios#0.16.2
├── bootstrap#3.3.7
├── bootstrap-sass#3.3.7
├── cross-env#5.0.5
├── font-awesome#4.7.0
├── jquery#3.2.1
├── laravel-mix#1.4.5
├── lodash#4.17.4
└── vue#2.4.4
Nothing is listed as extraneous.
Now, I'm trying to compile these assets (js and css) into 2 files, which are easy to include in the blade-template.
The docs say I have to use npm run dev, but this fails with the most cryptic message you can ever imagine.
events.js:141
throw er; // Unhandled 'error' event
^
Extras
Call stack:
Error: spawn node_modules/webpack/bin/webpack.js ENOENT
at exports._errnoException (util.js:907:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:189:32)
at onErrorNT (internal/child_process.js:363:16)
at nextTickCallbackWith2Args (node.js:511:9)
at process._tickCallback (node.js:425:17)
at Function.Module.runMain (module.js:443:11)
at startup (node.js:140:18)
at node.js:1043:3
The npm run dev command results in following command:
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
Versions:
npm ERR! node -v v4.8.2
npm ERR! npm -v 1.4.21
I've put the entire output online as well:
output
Why isn't it possible to compile the assets? How can I fix this?
EDIT:
All right found it!
somehow i reinstalled nodejs to not have the legacy-version.
These are the commmands I ran:
sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get -y install nodejs
sudo apt-get install dh-autoreconf
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
npm install bootstrap --save
npm list --depth=0
npm run dev
Try removing the contents of node_modules/
rm -Rfv your_project_path/node_modules/
then
npm install
Let me know if it helps.
Related
i want use laravel mix with npm run dev but
this return error:
webpack not installed
Install webpack to start bundling:
$ npm install --save-dev webpack
npm ERR! code 1
npm ERR! path C:\Users\taher\Desktop\kalashomar
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js"
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\taher\AppData\Local\npm-cache\_logs\2021-01-02T08_34_28_436Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\taher\Desktop\kalashomar
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "npm run development"
i tried this commands:
npm install --save-dev webpack
yarn add webpack --save-dev
npm cache clean --force
npm install
npm install cross-env --save-dev
i also removed package-lock.json and yarn.lock and renistall but still return this error
please help
first of fall download node.js ( https://nodejs.org/en/ ) or update in your device.
after successfully installed, try this..
npm install ,
npm run dev
today I started a new project on Laravel 5.7, but I have a problem when I try to npm run dev or run watch.
I did:
laravel new something
cd something
composer install
cp .env.example .env
php artisan key:generate
php artisan serve
perfect :D
but...
npm install
npm run dev
error!
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"
/Users/car/Sites/something/node_modules/webpack-cli/bin/cli.js:231
throw err;
^
If I try with run watch, same thing.
I tried:
rm -r nodes_modules
rm package-lock.json
npm install
same thing
What am I doing wrong?
Thanks!
Try
npm uninstall ajv
npm install ajv#6.8.1
To install an older version of ajv.
Ref: https://github.com/webpack/webpack/issues/8768
When I try to run npm run dev, I get this error. This is a fresh install, and I have it working with the same setup in another folder. I get the same error on another computer.
Versions
NPM: 5.3.0
Node: v8.4.0
test ⚑ → npm run dev master ✗ 2d
> # dev /Users/myuser/Code/testing/test
> 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
78% advanced chunk optimization/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188
chunk.sortModules();
^
TypeError: chunk.sortModules is not a function
at /Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188:19
at /Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3083:16
at eachOfArrayLike (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1003:9)
at eachOf (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1051:5)
at Object.eachLimit (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3145:5)
at Compilation.<anonymous> (/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:184:27)
at Compilation.applyPluginsAsyncSeries (/Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:206:13)
at Compilation.seal (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:579:8)
at /Users/myuser/Code/testing/test/node_modules/webpack/lib/Compiler.js:493:16
at /Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:289:11
at _addModuleChain (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:481:11)
at processModuleDependencies.err (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:452:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # 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`
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! /Users/myuser/.npm/_logs/2017-09-04T13_55_30_770Z-debug.log
the issue seems to be related to difference in packages, just today I was updating webapacker version 3 which uses webpack version 3 in rails app and I was getting this same error. The issue stoped when I updated this packages to this versions in the package.json file:
"sass-loader": "^6.0.6"
"babel-loader": "7.1.2"
"webpack": "^3.6.0"
Thanks to the suggestion of this guy: https://github.com/rails/webpacker/issues/852#issuecomment-331764386
I suggest that if you are using these packages you change to these versions to see if it works for you also.
This worked for me. When I used Yarn instead.
rm -rf node_modules
brew install yarn
yarn
yarn run dev
First, remove the webpack plugin. Then install and build yarn using the following steps:
npm install remove-webpack-plugin --save-dev
yarn install
yarn build
I am very new to react (started a day ago). I used the create-react-app command line to create an app. I tried in the following order
create-react-app my-app
npm start
At this point the app is running fine. Then I did the following
npm install youtube-api-search
npm start
Now i am getting this error
my-app#0.1.0 start /Users/shanmugharajk/Code/udemy/my-app
react-scripts start
sh: react-scripts: command not found npm ERR! file sh npm ERR! code
ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR!
my-app#0.1.0 start: react-scripts start npm ERR! spawn ENOENT npm
ERR! npm ERR! Failed at the my-app#0.1.0 start script. npm ERR! This
is probably not a problem with npm. There is likely additional logging
output above.
This happens every single time with any package I try to install.
One think I noted is when i run
npm install youtube-api-search or any pckage it always removes some package. The message I am getting while installing any package is
npm WARN registry Using stale data from https://registry.npmjs.org/
because the host is inaccessible -- are you offline? npm WARN registry
Unexpected warning for https://registry.npmjs.org/: Miscellaneous
Warning ENOTFOUND: request to https://registry.npmjs.org/redux failed,
reason: getaddrinfo ENOTFOUND registry.npmjs.org
registry.npmjs.org:443 npm WARN registry Using stale package data from
https://registry.npmjs.org/ due to a request error during
revalidation. npm WARN gentlyRm not removing
/Users/shanmugharajk/Code/udemy/my-app/node_modules/html-minifier/node_modules/.bin/uglifyjs
as it wasn't installed by
/Users/shanmugharajk/Code/udemy/my-app/node_modules/html-minifier/node_modules/uglify-js
npm WARN gentlyRm not removing
/Users/shanmugharajk/Code/udemy/my-app/node_modules/espree/node_modules/.bin/acorn
as it wasn't installed by
/Users/shanmugharajk/Code/udemy/my-app/node_modules/espree/node_modules/acorn
npm WARN gentlyRm not removing
/Users/shanmugharajk/Code/udemy/my-app/node_modules/autoprefixer/node_modules/.bin/browserslist
as it wasn't installed by
/Users/shanmugharajk/Code/udemy/my-app/node_modules/autoprefixer/node_modules/browserslist
npm notice created a lockfile as package-lock.json. You should commit
this file.
redux#3.7.1 added 3 packages, removed 1142 packages and updated 3 packages in 27.043s
I couldn't figure out the reason. Please help me.
You are using npm 5. At the moment it has many issues.
I recommend to downgrade to npm 4 and try again:
npm install -g npm#4
rm -rf node_modules
rm package-lock.json
npm install
If it doesn't help check your internet connection.
This looks like an issue with your network:
getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
I got the answer, since I had yarn and npm both installed in my machine the create-react-app uses yarn and installs all the dependencies and creates yarn.lock file.
So now when I run npm install it looks for package.lock.json and it wont be there. So it uninstalls some package creates by yarn at the time of creation of the project.
So the solution I found is do any of the following
create-react-app my-app
npm install
Then do install npm install -package-
Or
create-react-app my-app
yarn install -package-
Both of this approach is working now for me.
Basic requirement to run React app is:
nodejs
npm
If it is not installed then install this by(specifically for Ubuntu)
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
To create react js app:
npx create-react-app my-DemoApp
A
fter that go inside folder by:
cd my-DemoApp
You can see basic folder structure created by this
my-DemoApp
├── README.md
├── package.json
├── .gitignore
├── public
│ ├── favicon.ico
│ ├── index.html
│ └── manifest.json
└── src
├── App.css
├── App.js
├── App.test.js
├── index.css
├── index.js
├── logo.svg
└── serviceWorker.js
After than add basic dependency required by react app by running:
npm install
That will create new folder named : node_modules in your parent folder
You can now run your app by :
npm start
And now you are done with most basic setup, you're app is now ready.
You also can add more library which is mandatory for the app by npm
npm install -g npm
And then install create react app again:
npm install -g create-react-app
And then create the project again
I try install gulp in mac like this :
Is-iMac:~ itop$ npm root
/Users/itop/node_modules
Is-iMac:~ itop$ npm config set prefix /usr/local
Is-iMac:~ itop$ npm root -g
/usr/local/lib/node_modules
Is-iMac:~ itop$ sudo npm install -g gulp
After Install I see this error In terminal:
npm WARN deprecated graceful-fs#3.0.8: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs#^4.0.0 as soon as possible.
npm WARN deprecated lodash#1.0.2: lodash#<3.0.0 is no longer maintained. Upgrade to lodash#^4.0.0.
npm WARN deprecated graceful-fs#1.2.3: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs#^4.0.0 as soon as possible.
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "gulp"
npm ERR! node v5.6.0
npm ERR! npm v3.8.0
npm ERR! path /usr/local/bin/gulp
npm ERR! code EEXIST
npm ERR! Refusing to delete /usr/local/bin/gulp: ../lib/node_modules/gulp-cli/bin/gulp.js symlink target is not controlled by npm /usr/local
npm ERR! File exists: /usr/local/bin/gulp
npm ERR! Move it away, and try again.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/it/npm-debug.log
Now when i type gulp for start/run in terminal i see this error:
-bash: gulp: command not found
EDIT:
I try with this comment By archie-voyageur:
npm install --global gulp-cli
And See this error:
/usr/local/bin/gulp -> /usr/local/lib/node_modules/gulp-cli/bin/gulp.js
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--global" "gulp-cli"
npm ERR! node v5.6.0
npm ERR! npm v3.8.0
npm ERR! path /usr/local/share/man/man1/gulp.1
npm ERR! code EEXIST
npm ERR! Refusing to delete /usr/local/share/man/man1/gulp.1: ../../../lib/node_modules/gulp/gulp.1 symlink target is not controlled by npm /usr/local
npm ERR! File exists: /usr/local/share/man/man1/gulp.1
npm ERR! Move it away, and try again.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/itop/npm-debug.log
How do fix this?
Just came across this issue myself and managed to solve it with:
$ npm uninstall --global gulp gulp-cli
$ rm /usr/local/share/man/man1/gulp.1
$ npm install --global gulp-cli
go to
cd /usr/local/bin
ls -las
if gulp is present delete that directory. (sudo rm -rf gulp) reinstall
gulp-cli
===================================================================
if it is not working uninstall node, npm completely and try again
follow this link for step by step guide
node and npm uninstall step by step
I think you have gulp installed in your system, or at least you have some files related to gulp. Just do npm uninstall --global gulp gulp-cli and then try to install it again with npm install --global gulp-cli. If this doesn't work, I don't know what is happening on your system.
After pulling my hair out trying all of these, I ended up being able to install stupid gulp by doing
npm uninstall --global gulp gulp-cli
yarn global add gulp
For me it worked only when I installed gulp using npm instead of yarn. Very weird..