Cannot find module 'live-server' (locally installed) - npm

I have been trying to run babel and live-server locally , however when calling for 'npm run build' or 'npm run serve' I get the following error:
> boilerplate#1.0.0 serve C:\Users\sasaa\OneDrive\Documents\HTMl&CSS\j-14-05-globals\boilerplate
> live-server public
'CSS\j-14-05-globals\boilerplate\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module 'C:\Users\sasaa\OneDrive\Documents\live-server\live-server.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:17)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! boilerplate#1.0.0 serve: `live-server public`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the boilerplate#1.0.0 serve 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\sasaa\AppData\Roaming\npm-cache\_logs\2020-01-05T00_21_18_216Z-debug.log
This is the package-json:
{
"name": "boilerplate",
"version": "1.0.0",
"description": "",
"main": "input.js",
"scripts": {
"serve": "live-server public",
"build": "babel src/index.js --out-file public/scripts/bundle.js --presets env --watch"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"live-server": "^1.2.1"
}
}
I am using Windows 10 with Git Bash
npm version 6.13.4
node v13.5.0
Any suggestions how to solve this issue?

Related

Error trying to install Axios with npm in a Node.js project

I'm trying to install axios in a personal project for learning Node.js, mongoDB and express and I got stucked at an error when installing it with npm. The problem i get when executing npm i --save axios is this one:
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EPERM
npm ERR! syscall lstat
npm ERR! path F:\Laboral\Elonial\Curso Node.js\4-natours\node_modules\simple-swizzle
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, lstat 'F:\Laboral\Elonial\Curso Node.js\4-natours\node_modules\simple-swizzle'
npm ERR! [Error: EPERM: operation not permitted, lstat 'F:\Laboral\Elonial\Curso Node.js\4-natours\node_modules\simple-swizzle'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'lstat',
npm ERR! path: 'F:\\Laboral\\Elonial\\Curso Node.js\\4-natours\\node_modules\\simple-swizzle'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\djime\AppData\Local\npm-cache\_logs\2023-02-03T12_21_26_556Z-debug-0.log
I already tried installing it into the project with administrator permissions through cmd, but got same error. My package.json follows this right now:
{
"name": "natours",
"version": "1.0.0",
"description": "Project created by NukeSkull in order to learn node.js, express and mongoDB",
"main": "app.js",
"scripts": {
"start": "nodemon server.js",
"start:prod": "SET NODE_ENV=production&&nodemon server.js",
"debug": "ndb server.js",
"watch:js": "parcel watch ./public/js/index.js --out-dir ./public/js --out-file bundle.js",
"build:js": "parcel watch ./public/js/index.js --out-dir ./public/js --out-file bundle.js"
},
"author": "NukeSkull",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"express-mongo-sanitize": "^2.2.0",
"express-rate-limit": "^6.6.0",
"helmet": "^3.23.3",
"hpp": "^0.2.3",
"jsonwebtoken": "^8.5.1",
"mapbox-gl": "^2.12.0",
"mongoose": "^5.13.15",
"morgan": "^1.10.0",
"nodemailer": "^6.7.8",
"nodemon": "^2.0.19",
"pug": "^3.0.2",
"slugify": "^1.6.5",
"validator": "^13.7.0",
"xss-clean": "^0.1.1"
},
"devDependencies": {
"eslint": "^8.22.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"parcel-bundler": "^1.12.5",
"prettier": "^2.7.1"
},
"engines": {
"node": ">=10.0.0"
}
}
How can I solve this error so I can install axios?
Found my error, somehow windows antivirus was blocking me from installing it, disabling it allowed me to install axios. Thanks to #Samball for the answer

Having different errors with vue create and npm run serve

I'm new to vue and I'm having different errors trying to create new projects with vue create and executing npm run serve.
I've already tried reinstalling node and vue. Changed some PATH, but nothing worked.
First I created the application with:
vue create routing-overview
Then i got this in the final part:
added 1259 packages from 656 contributors in 37.319s
🚀 Invoking generators...
📦 Installing additional dependencies...
npm ERR! code EEXIST
npm ERR! path C:\Users\USER\Estudos\igti\m04-vue\routing-overview\node_modules\#babel\parser\bin\babel-parser.js
npm ERR! dest C:\Users\USER\Studies\m04-vue\routing-overview\parser
npm ERR! EEXIST: file already exists, cmd shim 'C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\#babel\parser\bin\babel-parser.js' -> 'C:\Users\USER\Studies\m04-vue\routing-overview\parser'
npm ERR! File exists: C:\Users\USER\Studies\m04-vue\routing-overview\parser
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Roaming\npm-cache\_logs\2021-09-10T19_38_16_412Z-debug.log
ERROR command failed: npm install --loglevel error
Opening the project folder on VS Code I have this error in the first import of main.js:
Parsing error: Cannot find module 'babel-eslint'
Require stack:
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\vue-eslint-parser\index.js
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\eslint-plugin-vue\lib\utils\index.js
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\eslint-plugin-vue\lib\rules\array-bracket-newline.js
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\eslint-plugin-vue\lib\index.js
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\eslint\lib\cli-engine\config-array-factory.js
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\eslint\lib\cli-engine\cli-engine.js
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\eslint\lib\cli-engine\index.js
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\eslint\lib\api.js
- c:\Users\USER\.vscode\extensions\dbaeumer.vscode-eslint-2.1.25\server\out\eslintServer.js
And when I try to npm run serve, i have a different error:
> routing-overview#0.1.0 serve C:\Users\USER\Studies\m04-vue\routing-overview
> vue-cli-service serve
internal/modules/cjs/loader.js:892
throw err;
^
Error: Cannot find module '#vue/cli-plugin-babel'
Require stack:
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\#vue\cli-service\lib\Service.js
- C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\#vue\cli-service\bin\vue-cli-service.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at idToPlugin (C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\#vue\cli-service\lib\Service.js:145:14)
at C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\#vue\cli-service\lib\Service.js:184:20
at Array.map (<anonymous>)
at Service.resolvePlugins (C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\#vue\cli-service\lib\Service.js:170:10)
at new Service (C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\#vue\cli-service\lib\Service.js:32:25)
at Object.<anonymous> (C:\Users\USER\Studies\m04-vue\routing-overview\node_modules\#vue\cli-service\bin\vue-cli-service.js:15:17) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\USER\\Studies\\m04-vue\\routing-overview\\node_modules\\#vue\\cli-service\\lib\\Service.js',
'C:\\Users\\USER\\Studies\\m04-vue\\routing-overview\\node_modules\\#vue\\cli-service\\bin\\vue-cli-service.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! routing-overview#0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the routing-overview#0.1.0 serve 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\USER\AppData\Roaming\npm-cache\_logs\2021-09-10T19_48_28_445Z-debug.log
And this is what I have on package.json:
{
"name": "routing-overview",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
I have no idea what is the problem. Any help is very much appreciated.
Try running:
$ npm install
in the same folder of your package.json file, then try it again.
Have you tried updating npm and node versions?. It's possible you need to update them.
Also, you can try cleaning npm cache data: npm cache clean --force . or you can do it manually by locating appData folder and then \npm-cache folder and delete it. then try running vue create routing-overview again
I was able to fix the problem, even not having a clue about what exactly was wrong.
I uninstalled vue and then Node from my PC. After that, I deleted any trace of node or npm from my PC following the comments from this post.
Then installed Node again and #vue/cli. Used npm init to create a new package.JSON and everything is working as expected right now.
Thanks for the help!

Why do I get this error trying to run this VUE JS repository?

This is a VUE JS MASONRY project on the GitHub. I just trying to run
it. I've already run the npm install before run it. It seems like the
all the packages have been installed properly.
PS C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master>npm start
> vue-masonry-demo#1.0.0 start C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master
> node build/dev-server.js
> Starting dev server...
events.js:187
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::8080
at Server.setupListenHandle [as _listen2] (net.js:1300:14)
at listenInCluster (net.js:1348:12)
at Server.listen (net.js:1436:7)
at Function.listen (C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master\build\dev-server.js:83:18)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1327:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 8080
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-masonry-demo#1.0.0 start: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-masonry-demo#1.0.0 start 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\Administrator\AppData\Roaming\npm-cache\_logs\2020-02-05T22_23_37_278Z-debug.log
PS C:\Users\Administrator\Downloads\vue-masonry-plugin-demo-master>
PACKAGE.JSON
{ "name": "vue-masonry-demo", "version": "1.0.0",
"description": "A Vue.js project", "author": "Mikhail Kuznetcov
", "private": true, "scripts": {
"dev": "node build/dev-server.js",
"start": "node build/dev-server.js",
"build": "node build/build.js" },
Error: listen EADDRINUSE: address already in use :::8080
If you check it here, you will figure it out.

having a problem with setting up my babel-watch in node.js

I am trying to install babel watch after I have installed babel
my json file is as follows
{
"name": "t3",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel server.js --out-dir build",
"dev-start": "babel-watch server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-watch": "^7.0.0"
}
}
but i am getting this error while running
npm run dev-start
t3#1.0.0 dev-start C:\Users\PRO\Desktop\t3
babel-watch server.js
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '#babel/core'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\Users\PRO\Desktop\t3\node_modules\babel-watch\babel-watch.js:7:15)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! t3#1.0.0 dev-start:
babel-watch server.js npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the t3#1.0.0 dev-start script. npm ERR! This is probably not
a problem with npm. There is likely additional logging output above.
[Update]
You might have update the babel. check out https://github.com/babel/babel/issues/8908 & How to upgrade to babel 7
Try
npm install #babel/core --save

npm run build - Insufficient number of arguments or no entry found

I am trying to build a project for the first time and I am getting an error message.
Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.
Hash: 83fdf40d8aadb2841816
Version: webpack 4.18.0
Time: 180ms
Built at: 09/11/2018 4:55:53 AM
ERROR in Entry module not found: Error: Can't resolve './src' in '/home/baudhi/website'
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! website#15.19.1 build: `webpack --mode production`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the website#15.19.1 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! /home/baudhi/.npm/_logs/2018-09-11T11_55_53_650Z-debug.log
The ebook I am reading has asked me to type 'npm run build' but it is not working. any help pls.
My package.json file looks like the following:
{
"name": "website",
"version": "15.19.1",
"description": "just practice",
"main": "main.js",
"scripts": {
"develop": "webpack --mode development --watch",
"build": "webpack --mode production"
},
"author": "pebaudhi",
"license": "ISC",
"devDependencies": {
"webpack": "^4.18.0",
"webpack-cli": "^3.1.0"
},
"dependencies": {
"jquery": "^3.3.1"
}
}
And my directory structure is:
/usr/baudhi/website/.babelrc
/usr/baudhi/website/package.json
/usr/baudhi/website/jquery-3.3.1.js
/usr/baudhi/website/src/main.js
/usr/baudhi/website/dist/main.js
node -v
v10.7.0
Thank you very much for helping me.
If you're using Webpack 4 the configuration has been defaulted. Hence, you don't need to provide a webpack.config.json file but you're project needs to follow the default config.
The default entry point in Webpack 4 is ./src/index.js. So either rename ./src/main.js or create webpack.config.js file with the following minimum.
module.exports = {
entry: './src/main.js'
};