I have created my react-app and only thereafter I added tailwind.
Currently this is my folder structure:
Package.json looks like this:
"scripts": {
"start": "postcss src/tailwind.css -o src/styles.css && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
I am unable to run my npm start script whenever I add postcss to the script and when I don't tailwind css is not applied to my project at all.
The error I am getting when I add postcss:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phshopper#0.1.0 start: `postcss src/tailwind.css -o src/styles.css && react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phshopper#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Thanks
Can you please check the below code? Hope it will work for you.
#1 You need to add postcss src/tailwind.css -o src/styles.css in "build:css" and
#2 Keep the file build command npm run build:css in "build" like below.
"scripts": {
"start": "react-scripts start",
"build": "npm run build:css && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"build:css": "postcss src/tailwind.css -o src/styles.css",
}
Related
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.
The default package manager in my system is Yarn. I am trying to follow a course that uses NPM. Instead of shifting to NPM, I wanted to continue in Yarn but I got stuck in concurrently. How can I convert the following code for Yarn?
"start": "node backend/server",
"server": "nodemon backend/server",
"client": "npm start --prefix frontend",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"data:import": "node backend/seeder",
"data:destroy": "node backend/seeder -d",
yarn version for above code will be:
"start": "node backend/server",
"server": "nodemon backend/server",
"client": "yarn --cwd frontend start",
"dev": "concurrently \"yarn server\" \"yarn client\"",
"data:import": "node backend/seeder",
"data:destroy": "node backend/seeder -d"
CWD - current working directory
When I run yarn start or any other following scripts:
"scripts": {
"start": "webpack-dev-server --config scripts/webpack.dev.js",
"clean": "rimraf build",
"build": "yarn run clean && yarn run compile",
"compile": "webpack --config scripts/webpack.prod.js",
"compile-for-test": "webpack --config scripts/webpack.test.prod.js",
"build-for-test": "yarn run clean && yarn run compile-for-test",
"test": "jest -c scripts/jest.config.js --testPathIgnorePatterns=\"services/contract-tests\"",
"test-ci": "node scripts/test-shell-commands.js unitTestCI",
"test-contract": "node scripts/test-shell-commands.js testLocal",
"test-contract-ci": "node scripts/test-shell-commands.js testCI",
"coverage": "node scripts/test-shell-commands.js unitTestCoverage",
"lint": "./node_modules/.bin/eslint --max-warnings=0 \"src/**\"",
"start-backend": "bash -l ./scripts/start-backend-container.sh",
"stop-backend": "bash -l ./scripts/stop-backend-container.sh",
"start-stub": "bash -l ./scripts/start-backend-stub-container.sh",
"stop-stub": "bash -l ./scripts/stop-backend-stub-container.sh",
"prettier": "prettier --write **/*{ts,tsx}"
},
I get the following error:
# yarn start
$ webpack-dev-server --config scripts/webpack.dev.js
error Couldn't find the binary webpack-dev-server --config scripts/webpack.dev.js
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
# yarn test
$ jest -c scripts/jest.config.js --testPathIgnorePatterns="services/contract-tests"
error Couldn't find the binary jest -c scripts/jest.config.js --testPathIgnorePatterns="services/contract-tests"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This applies to all scripts (its not spesific to webpack etc). However, when I use it npm run start, it works. yarn add or yarn commands alone also work. Just I can't run any script with yarn.
Does anyone encountered this before?
My yarn version is: 1.22.10
I have uninstalled and installed a few times but the problem continues. OS: Windows
This might be an issue with node trying to spawn a command on windows when specifying bash as the shell since Yarn uses node's child_process.spawn.
The shell-script specified in .yarnrc, passes that shell as the shell option to spawn, and when a shell is specified and process.platform evaluates to win32, ['/d', '/s', '/c' will be tacked in the arguments (see below source of spawn()).
if (options.shell) {
const command = [file].concat(args).join(' ');
if (process.platform === 'win32') {
if (typeof options.shell === 'string')
file = options.shell;
else
file = process.env.comspec || 'cmd.exe';
args = ['/d', '/s', '/c', `"${command}"`];
options.windowsVerbatimArguments = true;
Please check your yarn configuration via yarn config get script-shell in order to verify the settings of the bash-path.
See child_process.spawn for more info..
I want to use npm postinstall hook in my package to achieve my requirement. is this safe to use, I mean will it create security issues?
I am using like below:
"scripts": {
"postinstall" : "node ./tagchange.js",
"scripts": "gulp schematics-tasks && gulp schematics-remove && gulp adding-externals && npm run packagr",
"bundle": "rollup -c rollup.config.js"
},
I'm tring to use https://github.com/intljusticemission/react-big-calendar after forking
I can jspm install -dev github:pcompassion/react-big-calendar fine.
But it's lacking lib directory, I think jspm is not running "scripts" in package.json (Is it supposed to do?)
"scripts": {
"clean": "rimraf lib",
"clean:examples": "rimraf examples/static",
"less": "lessc --autoprefix=\"ie >= 10, last 2 versions\" src/less/styles.less ./lib/css/react-big-calendar.css",
"assets": "cpy src/less/* lib/less",
"build": "npm run clean && babel src --out-dir lib && npm run assets && npm run less",
"build:examples": "npm run clean:examples && webpack --config webpack/examples.config.es6.js",
"build:visual-test": "webpack --config webpack/visual-test.es6.js",
"examples": "npm run clean:examples && webpack-dev-server --inline --hot --config webpack/examples.config.es6.js",
"lint": "eslint src --ext .jsx --ext .js",
"storybook": "start-storybook -p 9002",
"test": "npm run lint",
"tdd": "karma start",
"release": "release"
},
So I should go to the folder and mannualy do npm install ?