Trying Laravel jetstream but getting an error on "npm run dev" - node.js

lam getting the error below while running npm run dev
[webpack-cli] TypeError: this.program.configureOutput is not a function
at new WebpackCLI (/home/vagrant/sites/ecom/node_modules/webpack-cli/lib/webpack-cli.js:19:22)
at runCLI (/home/vagrant/sites/ecom/node_modules/webpack-cli/lib/bootstrap.js:7:21)
at Object. (/home/vagrant/sites/ecom/node_modules/webpack-cli/bin/cli.js:23:5)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at runCli (/home/vagrant/sites/ecom/node_modules/webpack/bin/webpack.js:54:2)
npm ERR! code 2
npm ERR! path /home/vagrant/sites/ecom
npm ERR! command failed
npm ERR! command sh -c mix
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2021-03-19T11_14_07_947Z-debug.log
npm ERR! code 2
npm ERR! path /home/vagrant/sites/ecom
npm ERR! command failed
npm ERR! command sh -c npm run development
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2021-03-19T11_14_07_974Z-debug.log

First, try to update your node.js file and then run "npm run dev" and if you again faced the same problem follow the following steps:
Step1: composer update
Step2: rm -rf node_modules
Step3: npm cache clear --force
Step4: npm install
Step5: npm outdated
In this step, it will update your laravel-mix version, it is in the package.json.
Step6: npm install
Step7: npm run dev
After all these steps, everything is good.
I hope it solve your problem.

I came across this problem when trying to build and run webpack (and webpack-cli locally), after check out from Github (not at all related to Laravel).
I found that I forgot to run yarn install for webpack-cli which lead to the issue that an existing version of commander#6 was used, but webpack-cli requires commander#7.
npm list commander should tell you that the webpack-cli dependency is unsatisfied. yarn install should fix it.

Related

Cannot find module typescript.js after Windows restoration point. I'm triying to build my angular app

I had problems with my PC and I restored windows to and old restoration point.
After this... When I try to build my Angular App I have the next error:
C:\Udemy\AngularDeCeroAExpertoEdicion2021\03-paisesApp>npm run build
> paises-app#0.0.0 build C:\Udemy\AngularDeCeroAExpertoEdicion2021\03-paisesApp
> npm run config -- --environment=prod && ng build --prod
> paises-app#0.0.0 config C:\Udemy\AngularDeCeroAExpertoEdicion2021\03-paisesApp
> ts-node ./src/assets/scripts/setEnv.ts "--environment=prod"
internal/modules/cjs/loader.js:329
throw err;
^
Error: Cannot find module 'C:\Udemy\AngularDeCeroAExpertoEdicion2021\03-paisesApp\node_modules\typescript\lib\typescript.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:321:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:534:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
at Function.resolve (internal/modules/cjs/helpers.js:98:19)
at loadCompiler (C:\Users\myuser\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:208:34)
at create (C:\Users\myuser\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:213:28)
at Object.register (C:\Users\myuser\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:184:21)
at main (C:\Users\myuser\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:129:29)
at Object.<anonymous> (C:\Users\myuser\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:448:5)
at Module._compile (internal/modules/cjs/loader.js:1085:14) {
code: 'MODULE_NOT_FOUND',
path: 'C:\\Udemy\\AngularDeCeroAExpertoEdicion2021\\03-paisesApp\\node_modules\\typescript\\package.json',
requestPath: 'typescript'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! paises-app#0.0.0 config: `ts-node ./src/assets/scripts/setEnv.ts "--environment=prod"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the paises-app#0.0.0 config 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! C:\Users\myuser\AppData\Roaming\npm-cache\_logs\2021-08-01T08_27_09_159Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! paises-app#0.0.0 build: `npm run config -- --environment=prod && ng build --prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the paises-app#0.0.0 build 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! C:\Users\myuser\AppData\Roaming\npm-cache\_logs\2021-08-01T08_27_09_186Z-debug.log
I think that the problem is with the directory:
C:\Users\myuser\AppData\Roaming\npm\node_modules\
What can I do?
remove the folder node_modules?
reinstall npm?
I tried with npm install and all is ok.
Thanks.
Edited:
Maybe the problem was in my merged branches or something like that.
Since you have not specified what was the installed state of apps when the restoration point was lastly set, I presume that you have all the npm packages captured correctly at that point. If so, try doing the below steps...
Since you have not included the entire log with this, I can guess it is possibly an ambiguity issue due to references not properly resolved!
Open command prompt/powershell/terminal, etc. with admin privilege. Do as below (sudo command not to be used with Windows OS): -
sudo npm cache clean --force
sudo npm cache verify
Delete the package-lock.json file located at C:\Users\<your_username>
Try installing your project dependencies now from your project folder with npm i or yarn install (if you're using yarn as your preferred package manager).
Note: - If this doesn't work, follow the same process as above (again) and uninstall npm/yarn and node and reinstall it. It should work then!
I have fixed it by doing the following:
Remove the folder /node_modules of my Angular App.
Run npm install.
And then run npm run build or npm run start or ng serve.
I have also found a package that does the same. The package name is reinstall
reinstall
Reinstall package's node modules without cache.
Removes node_modules directory
Clean's NPM cache
Install's modules from package.json
npm install reinstall -g
Once installed remember restart your terminal and run reinstall in your root dir.
Maybe the problem was in my merged branches or something like that.

Install expo cli errors at the end of install

So I'm following this tutorial to try and learn React Native: https://www.youtube.com/watch?v=qSRrxpdMpVc
And in the tutorial he shows to install expo cli using the line
'npm install expo-cli --global'
But when i run that line, i get a whole bunch of warnings saying for example:
npm WARN deprecated topo#3.0.3: This module has moved and is now available at #hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
In the tutorial he says to ignore this but at the end of the install i get this error:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! envsub#3.1.0 postinstall: `test -d .git && cp gitHookPrePush.sh .git/hooks/pre-push || true`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the envsub#3.1.0 postinstall 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! C:\Users\Alex\AppData\Roaming\npm-cache\_logs\2019-12-06T01_25_52_024Z-debug.log
and then when i try to run the line 'expo init first-app' to create a project i get this error:
Error: Cannot find module 'C:\Users\Alex\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js'
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:690:27)[39m
[90m at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)[39m
[90m at internal/main/run_main_module.js:17:11[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: []
}
I also found a similar question with an answer of try running
npm cache clean --force
npm install -g expo-cli
So i tried that but it didnt work.
Does anyone know why i would be getting these errors? I tried reinstalling node but that doesnt seem to fix it. Thanks for the help in advance, keep in mind i am completely new to react native
Assuming that you have Node 10 LTS or greater installed, you can use npm to install the Expo CLI command line utility:
npm install -g expo-cli
expo init AwesomeProject
cd AwesomeProject
npm start # you can also use: expo start

Failed at the #angular/cli#8.3.19 postinstall script

Hi I can't install the angular cli with npm install -g #angular/cli#8.3.19.
I keep getting this :
> node ./bin/postinstall/script.js
module.js:549
throw err;
^
Error: Cannot find module '/root/.nvm/versions/node/v13.0.1/lib/node_modules/#angular/cli/bin/postinstall/script.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #angular/cli#8.3.19 postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #angular/cli#8.3.19 postinstall 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! /root/.npm/_logs/2019-11-26T00_10_33_515Z-debug.log
Node version : 13.0.1
Npm version : 6.13.1
Ubuntu version : 18.04.2
I also tried without specifying a CLI version.
I tried with this command that I found online :
npm install -g #angular/cli#8.3 --unsafe-perm=true --allow-root
And it worked.
Try to run with sudo npm. On Ubuntu, you need to run with root permission. It depends on how you install node.
sudo npm install -g #angular/cli#8.3.19
On the other hand, try to install node 12 and LTS versions to have a more secure version.
Hope it helps
Try clean your npm cache before npm cache clean or npm cache verify then npm install -g #angular/cli#8.3 --unsafe-perm=true --allow-root
Steps I followed
Downgrade node version using nvm to v12.3.0
Remove ng folder from /root/.nvm/versions/node/v12.3.0/bin
Again do npm install -g #angular/cli#8.3 --unsafe-perm=true --allow-root
and it worked

Can't install any Node packages globally Ubuntu Digital Ocean

Tried everything. Tried all the steps below, didn't work so I nuked my droplet and rebuilt to start over and try again. I'm Using Ubuntu. First thing once I ssh into my droplet was install node and npm via:
https://nodejs.org/en/download/package-manager/
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Then
npm -v
5.6.0
node -v
v8.11.3
Then I try to install a package globally. I tried electron and it failed so I began messing with the node modules folder as I was getting the permission error with the fix documented here:
https://askubuntu.com/questions/869168/node-modules-have-755-permissions-what-permissions-should-i-set-so-that-npm-don
No luck. So I tried the solution documented here:
NPM global install "cannot find module"
echo $NODE_PATH
/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript:/home/username/.npm-global/lib/node_modules
So that didn't work either. This is the error now when I try and install any package globally:
npm install -g electron
I get:
Error: Cannot find module '/root/.npm-global/lib/node_modules/nightmare/node_modules/electron/install.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron#1.8.7 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron#1.8.7 postinstall 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! /root/.npm/_logs/2018-08-03T03_26_03_827Z-debug.log
This error for any package I try to install. Not sure what else to try. Don't want to wipe out the droplet and start over...
I also had this issue but after adding sudo at start the issue went away.
like:
sudo npm -g install nodemon

Where has JSBin been installed?

I wanted to follow this page to run JSBin locally.
I just installed xcode 8.2 in my mac. Now, npm -v returns 3.10.9; node -v returns v7.2.1. npm install returns
/Users/softtimur/Startup/WebProjects/jsbin$ npm install
> jsbin#3.40.2 postinstall /Users/softtimur/Startup/WebProjects/jsbin
> grunt build && npm run selenium:install
Running "concat:dist" (concat) task
File "public/js/prod/jsbin-3.40.2.js" created.
Running "concat:runner" (concat) task
File "public/js/prod/runner-3.40.2.js" created.
Running "uglify:dist" (uglify) task
File "public/js/prod/jsbin-3.40.2.min.js" created.
Running "uglify:runner" (uglify) task
File "public/js/prod/runner-3.40.2.min.js" created.
Running "uglify:embed" (uglify) task
File "public/js/embed.min.js" created.
Running "uglify:addons" (uglify) task
File "public/js/prod/addon-tern-3.40.2.min.js" created.
Done, without errors.
> jsbin#3.40.2 selenium:install /Users/softtimur/Startup/WebProjects/jsbin
> selenium-standalone install
----------
selenium-standalone installation starting
----------
---
selenium install:
from: https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
to: /Users/softtimur/Startup/WebProjects/jsbin/node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.25/chromedriver_mac64.zip
to: /Users/softtimur/Startup/WebProjects/jsbin/node_modules/selenium-standalone/.selenium/chromedriver/2.25-x64-chromedriver
---
firefox install:
from: https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-macos.tar.gz
to: /Users/softtimur/Startup/WebProjects/jsbin/node_modules/selenium-standalone/.selenium/geckodriver/0.11.1-x64-geckodriver
---
File from https://chromedriver.storage.googleapis.com/2.25/chromedriver_mac64.zip has already been downloaded
---
File from https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar has already been downloaded
---
File from https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-macos.tar.gz has already been downloaded
-----
selenium-standalone installation finished
-----
> jsbin#3.40.2 prepublish /Users/softtimur/Startup/WebProjects/jsbin
> npm run snyk-protect
> jsbin#3.40.2 snyk-protect /Users/softtimur/Startup/WebProjects/jsbin
> snyk protect
Successfully applied Snyk patches
It seems that jsbin has been installed, however, I could not find it under /usr/local/lib/node_modules/npm/node_modules/.
Does anyone know where it is?
Edit 1: npm start returns:
/Users/softtimur/Startup/WebProjects/jsbin$ npm start
> jsbin#3.40.2 start /Users/softtimur/Startup/WebProjects/jsbin
> (sleep 2 && open http://localhost:3000) & ./bin/jsbin
Config from /Users/softtimur/Startup/WebProjects/jsbin/lib/config.local.json
module.js:472
throw err;
^
Error: Cannot find module '/Users/softtimur/Startup/WebProjects/jsbin/node_modules/sqlite3/lib/binding/node-v51-darwin-x64/node_sqlite3.node'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/softtimur/Startup/WebProjects/jsbin/node_modules/sqlite3/lib/sqlite3.js:4:15)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node/7.2.1/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.2.1
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! jsbin#3.40.2 start: `(sleep 2 && open http://localhost:3000) & ./bin/jsbin`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jsbin#3.40.2 start script '(sleep 2 && open http://localhost:3000) & ./bin/jsbin'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jsbin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! (sleep 2 && open http://localhost:3000) & ./bin/jsbin
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs jsbin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls jsbin
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/softtimur/Startup/WebProjects/jsbin/npm-debug.log
Additionally, I think .bin/jsbin it runs is what has been inside the git folder; it was not built by my npm install.
I could not find it under /usr/local/lib/node_modules/npm/node_modules/
That is to be expected, because you copied the package repo to ~/Startup/WebProjects/jsbin, for use in development, as opposed to using npm install -g jsbin to install it globally, for regular use.
Using npm start from ~/Startup/WebProjects/jsbin, as Benjamin suggests, is the right approach.
npm start does find the jsbin executable, namely in subfolder ./bin (if you look in package.json, key "scripts", you'll see line
"start": "(sleep 2 && open http://localhost:3000) & ./bin/jsbin").
The error message you're getting is actually generated by jsbin itself, indicating a problem with the package's installation.

Resources