I have :
$ nodejs --version
v8.9.4
$ npm --version
5.6.0
I try to join that https://github.com/wxs77577/adminify vuejs/vuetify template with latest laravel.
I do as next:
1) laravel new Songs
2) cd Songs
php artisan --version
Laravel Framework 5.6.8
3) I copied all files from adminify/src/ into /resources/assets/js/ in Songs project folder
4) I modified my webpack.mix.js as :
let mix = require('laravel-mix');
mix.js('resources/assets/js/main.js', 'public/js') // main.js is entry point of the project
.sass('resources/assets/sass/app.scss', 'public/css');
5) Into my resources/assets/js/http.js I added axios headers configuration from Laravel's resources/assets/js/bootstrap.js, so it has content :
import Vue from 'vue'
import axios from 'axios'
import config from './config'
// enable mock
// import mock from './mock'
// if (!config.debug.mock) {
// mock.restore()
// }
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
/**
* Next we will register the CSRF Token as a common header with Axios so that
* all outgoing HTTP requests automatically have it attached. This is just
* a simple convenience so we don't have to attach every token manually.
*/
let token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
var http = axios.create({
baseURL: config.api,
timeout: 1000
// headers: { 'Authorization': 'Bearer ' + localStorage.getItem('token') }
})
http.interceptors.request.use(function (request) {
return request
}, function (error) {
// Do something with request error
return Promise.reject(error)
})
http.interceptors.response.use(function (response) {
const request = response.config
if (config.debug.http) {
console.log(
'>>>', request.method.toUpperCase(), request.url, request.params,
'\n ', response.status, response.data
)
}
return response
}, function (error) {
if (config.debug.http) {
let { response, config: request } = error
if (request) {
console.log(
'>>>', request.method.toUpperCase(), request.url, request.params,
'\n ', response.status, response.data
)
}
}
// Do something with response error
return Promise.reject(error)
})
Vue.prototype.$http = http
6) In package.json I added dependencies from adminify/package.json, so now my /package.json has content :
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"dependencies": {
"adonis-websocket-client": "^1.0.2",
"babel-runtime": "^6.23.0",
"i": "^0.3.5",
"indicative": "^2.2.1",
"vue": "^2.3.3",
"vue-i18n": "^6.1.1",
"vue-quill-editor": "^2.1.6",
"vue-router": "^2.3.1",
"vue-timeago": "^3.3.1",
"vue2-dropzone": "^2.0.0"
},
"devDependencies": {
"axios": "^0.18",
"bootstrap": "^4.0.0",
"popper.js": "^1.12",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^2.0",
"lodash": "^4.17.4",
"vue": "^2.5.7"
"Validator": "^1.0.4",
"autoprefixer": "^6.7.2",
"axios-mock-adapter": "^1.8.1",
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.10",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^1.1.3",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"eslint": "^3.19.0",
"eslint-config-standard": "^6.2.1",
"eslint-friendly-formatter": "^2.0.7",
"eslint-loader": "^1.7.1",
"eslint-plugin-html": "^2.0.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^2.0.1",
"eventsource-polyfill": "^0.9.6",
"express": "^4.14.1",
"extract-text-webpack-plugin": "^2.0.0",
"file-loader": "^0.11.1",
"friendly-errors-webpack-plugin": "^1.1.3",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.17.3",
"indicative": "^2.2.1",
"mockjs": "^1.0.1-beta3",
"opn": "^4.0.2",
"optimize-css-assets-webpack-plugin": "^1.3.0",
"ora": "^1.2.0",
"pug": "^2.0.0-rc.1",
"rimraf": "^2.6.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"style-loader": "^0.13.1",
"stylus": "^0.54.5",
"stylus-loader": "^2.1.1",
"url-loader": "^0.5.8",
"vue-loader": "^12.1.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.3.3",
"vuetify": "^0.14",
"vuex": "^2.3.1",
"webpack": "^2.6.1",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-hot-middleware": "^2.18.0",
"webpack-merge": "^4.1.0"
}
}
7) After that I run
$ npm install
npm WARN The package vue is included as both a dev and production dependency.
npm WARN The package indicative is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
8) and last :
$ npm run watch-poll
> # watch-poll /mnt/_work_sdb8/wwwroot/lar/Songs
> npm run watch -- --watch-poll
> # watch /mnt/_work_sdb8/wwwroot/lar/Songs
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch-poll"
10% building modules 1/1 modules 0 active
Webpack is watching the files…
78% advanced chunk optimization/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/laravel-mix/node_modules/extract-text-webpack-plugin/dist/index.js:188
chunk.sortModules();
^
TypeError: chunk.sortModules is not a function
at /mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/laravel-mix/node_modules/extract-text-webpack-plugin/dist/index.js:188:19
at /mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/async/dist/async.js:3096:16
at eachOfArrayLike (/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/async/dist/async.js:1055:9)
at eachOf (/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/async/dist/async.js:1103:5)
at Object.eachLimit (/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/async/dist/async.js:3158:5)
at Compilation.<anonymous> (/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/laravel-mix/node_modules/extract-text-webpack-plugin/dist/index.js:184:27)
at Compilation.applyPluginsAsyncSeries (/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/tapable/lib/Tapable.js:206:13)
at Compilation.seal (/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/webpack/lib/Compilation.js:579:8)
at /mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/webpack/lib/Compiler.js:493:16
at /mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/tapable/lib/Tapable.js:289:11
at _addModuleChain (/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/webpack/lib/Compilation.js:481:11)
at processModuleDependencies.err (/mnt/_work_sdb8/wwwroot/lar/Songs/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! # watch: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch-poll"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # watch 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/serge/.npm/_logs/2018-03-07T12_24_13_366Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # watch-poll: `npm run watch -- --watch-poll`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # watch-poll 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/serge/.npm/_logs/2018-03-07T12_24_13_388Z-debug.log
Content of 018-03-07T12_33_56_015Z-debug.log :
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'development' ]
2 info using npm#5.6.0
3 info using node#v8.9.4
4 verbose run-script [ 'predevelopment', 'development', 'postdevelopment' ]
5 info lifecycle #~predevelopment: #
6 info lifecycle #~development: #
7 verbose lifecycle #~development: unsafe-perm in lifecycle true
8 verbose lifecycle #~development: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/.bin:/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/mnt/_work_sdb8/wwwroot/lar/Songs/node_modules/.bin:/home/serge/.composer/vendor/bin:/home/serge/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle #~development: CWD: /mnt/_work_sdb8/wwwroot/lar/Songs
10 silly lifecycle #~development: Args: [ '-c',
10 silly lifecycle 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ]
11 silly lifecycle #~development: Returned: code: 1 signal: null
12 info lifecycle #~development: Failed to exec development script
13 verbose stack Error: # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid #
15 verbose cwd /mnt/_work_sdb8/wwwroot/lar/Songs
16 verbose Linux 4.13.0-36-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "development"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
22 error Exit status 1
23 error Failed at the # development script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
You have a problem with your webpack configuration. A couple of options:
Fix the imports
In ./resources/assets/js/i18n/index.js:
Replace:
import config from '#/config'
with:
import config from '../config'
And in /resources/assets/js/main.js:
Replace:
import '#/styles/main.styl'
with:
import './styles/main.styl'
Try the above. If it doesn't work, undo it and try the one below.
Alternative: Changing webpack config
If you are going to try this option, undo the suggested changes above.
To update your webpack config, in your webpack.mix.js, which is like:
let mix = require('laravel-mix');
mix.js('resources/assets/js/main.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
Add a mix.webpackConfig({, making it like:
let mix = require('laravel-mix');
mix.webpackConfig({
resolve:{
/* Path Shortcuts */
alias:{
'#': path.resolve(__dirname, 'resources/assets/js')
}
}
})
mix.js('resources/assets/js/main.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
Related
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
I have laravel 5.8 installed and I want to use vue in it. I tried running following commands.
I am running it on ubuntu, node version is 10.19.
1. npm install
2. npm run watch
First command runs okay and gave some warnings. When I run npm run watch I get following errors.
I am kind of new so any help is appreciated.
[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.module.rules[10] has an unknown property 'loaders'. These properties are valid:
object { assert?, compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }
-> A rule description with conditions and effects for modules.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # development 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/admin/.npm/_logs/2021-12-07T09_49_10_144Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # watch: `npm run development -- --watch`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # watch script.
npm ERR! This is probably not a problem with npm.
My package.json is as follows
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.24.0",
"bootstrap": "^4.1.0",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^4.1.4",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"resolve-url-loader": "^3.1.0",
"sass": "^1.44.0",
"sass-loader": "^7.3.1",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.14",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.6.0"
},
"dependencies": {}
}
Installing "webpack": "^5.41.1" with npm i -S webpack#latest will fix this issue.
I have a Vue app which I am trying to run using npm run start, but this gives me the following error when I run the command from either PowerShell or inside the VS Code terminal:
> economyapp#0.1.0 start C:\_code\myapp
> npx vue-cli-service serve
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/vue-cli-service - Not found
npm ERR! 404
npm ERR! 404 'vue-cli-service#latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2020-11-28T17_22_02_307Z-debug.log
Install for [ 'vue-cli-service#latest' ] failed with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! economyapp#0.1.0 start: `npx vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the economyapp#0.1.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\User\AppData\Roaming\npm-cache\_logs\2020-11-28T17_22_02_401Z-debug.log
The npm run start command works when I run it from inside WSL, however the server does not hot reload when I make changes to the code. I have tried uninstalling and reinstalling Vue CLI and running npm install.
Here is my package.json:
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "npx vue-cli-service serve",
"build": "npx vue-cli-service build",
"test": "npx vue-cli-service test:unit",
"lint": "npx vue-cli-service lint",
"serve": "npx vue-cli-service serve"
},
"dependencies": {
"axios": "^0.21.0",
"core-js": "^3.4.3",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"register-service-worker": "^1.6.2",
"store2": "^2.11.1",
"vue": "^3.0.0",
"vue-router": "^3.1.3",
"vuex": "^3.1.2"
},
"devDependencies": {
"#types/jest": "^24.0.19",
"#typescript-eslint/eslint-plugin": "^2.28.0",
"#typescript-eslint/parser": "^2.28.0",
"#vue/cli-plugin-babel": "^4.1.0",
"#vue/cli-plugin-eslint": "^4.1.0",
"#vue/cli-plugin-pwa": "^4.1.0",
"#vue/cli-plugin-router": "^4.1.0",
"#vue/cli-plugin-typescript": "^4.3.1",
"#vue/cli-plugin-vuex": "^4.1.0",
"#vue/cli-service": "^4.2.3",
"#vue/devtools": "^5.3.3",
"#vue/eslint-config-prettier": "^5.0.0",
"#vue/eslint-config-typescript": "^5.0.2",
"#vue/test-utils": "1.0.0-beta.29",
"eslint": "^6.0.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-vue": "^6.0.0",
"lint-staged": "^9.4.3",
"prettier": "^1.19.1",
"typescript": "^3.8.3",
"vue-template-compiler": "^2.6.10"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,vue,ts}": [
"vue-cli-service lint",
"git add"
]
}
}
TL;DR: Run npm install.
vue-cli-service is provided by the #vue/cli-service in your devDependencies. Because you don't specify the package in the npx command, it fails if it has to look in the registry. Without npx, your npm script will look in node_modules/.bin for vue-cli-service. You can remove npx from your npm scripts and you should see the same results you're getting now.
The fact that npx isn't finding vue-cli-service indicates that you have not run npm install. Do that and your npm scripts should work as is. Without running npm install, you will certainly run into other issues once you fix this one.
If, for some reason, you want the npm scripts to work without running npm install, you can tell npx where to find the binary in the registry. Change npx vue-cli-service in your npm scripts to be npx -p #vue/cli-service vue-cli-service instead and it should fix this problem. But you will certainly run into other problems. You'll want npm install regardless.
But to really get at the root of things, you'll need to figure out why the difference between WSL and non-WSL environments in your setup. My guess is that you have #vue/cli-service installed globally somewhere that only WSL finds it in your PATH but that's just a guess.
I'm trying to create an application using Django framework as a back-End and React.js as the front-End. the django portion works just fine, but when trying to integrate the react with my app. I get npm ERR! code ELIFECYCLE
npm ERR! errno 2. I am fairly new to this technology and I don't quiet understand where the error is coming from.
I tried cleaning up the cache and deleting the node_modules repo and then npm install but it didn't work. so i turn to you asking for help skilled programmers
this the error i get:
ERROR in Entry module not found: Error: Can't resolve './gentelella/frontend/src/index.js' in 'C:\Users\USER\Desktop\finale\django-gentelella\gentelella'
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! gentelella#1.0.0 build: `webpack --mode production ./gentelella/frontend/src/index.js --output ./gentelella/frontend/static/frontend/main.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the gentelella#1.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\USER\AppData\Roaming\npm-cache\_logs\2019-05-22T10_24_53_635Z-debug.log
and this is the package.json:
{
"name": "gentelella",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"devDependencies": {
"#babel/core": "^7.4.4",
"#babel/preset-env": "^7.4.4",
"#babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.6",
"babel-plugin-transform-class-properties": "^6.24.1",
"webpack": "^4.32.0",
"webpack-cli": "^3.3.2"
},
"scripts": {
"dev": "webpack --mode development ./gentelella/frontend/src/index.js --output ./gentelella/frontend/static/frontend/main.js",
"build": "webpack --mode production ./gentelella/frontend/src/index.js --output ./gentelella/frontend/static/frontend/main.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}
It seems to me like your path is wrong. Try using removing the gantelella folder from the path, so this leaves 'frontend/src/index.js'.
This assumes you have structured your folders like this:
C:\Users\USER\Desktop\finale\django-gentelella\gentelella\frontend\src\index.js
This question already has answers here:
Angular2 QuickStart npm start is not working correctly
(32 answers)
Closed 6 years ago.
I got error, when I create angular 2 application. I follow link create sample application. when I run
npm start
I got bellow error,
events.js:154
throw er; // Unhandled 'error' event
^
Error: watch node_modules/weinre/web/weinre/target/WiRuntimeImpl.amd.js ENOSPC
at exports._errnoException (util.js:856:11)
at FSWatcher.start (fs.js:1313:19)
at Object.fs.watch (fs.js:1341:11)
at createFsWatchInstance (/home/mts/project/testSails1/frontend/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/mts/project/testSails1/frontend/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/mts/project/testSails1/frontend/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleFile (/home/mts/project/testSails1/frontend/node_modules/chokidar/lib/nodefs-handler.js:255:21)
at FSWatcher.<anonymous> (/home/mts/project/testSails1/frontend/node_modules/chokidar/lib/nodefs-handler.js:473:21)
at FSReqWrap.oncomplete (fs.js:82:15)
I got npm logs like this,
npm
ERR! Linux 3.19.0-51-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "lite"
npm ERR! node v5.6.0
npm ERR! npm v3.8.0
npm ERR! code ELIFECYCLE
npm ERR! frontend#1.0.0 lite: `lite-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend#1.0.0 lite script 'lite-server'.
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 frontend package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! lite-server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs frontend
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls frontend
npm ERR!
There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/mts/project/testSails1/frontend/npm-debug.log
npm run lite exited with code 1
How I solve this?
That means you have already run the app, then you attempted to run it one more time without stopping the last run. Therefore, it was conflicted. You must stop the last run <=> click the stop button (red-square button on debug panel).
My previous package.json is,
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"typings": "typings",
"postinstall": "typings install"
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.8",
"systemjs": "0.19.22",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"zone.js": "0.5.15"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.1.0",
"typescript": "^1.8.2",
"typings":"^0.6.8"
}
}
I added to package.json like this,
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "concurrently \"npm run tsc:w\" \"npm run http\" ",
"tsc": "tsc",
"tsc:w": "tsc -w",
"http": "http-server -p 3000 -a 127.0.0.1 -o",
"typings": "typings",
"postinstall": "typings install"
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.8",
"systemjs": "0.19.22",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"zone.js": "0.5.15"
},
"devDependencies": {
"concurrently": "^2.0.0",
"http-server": "^0.9.0",
"typescript": "^1.8.2",
"typings":"^0.6.8"
}
}
now project working find.
there are change only lite ==> http then working find