tailwind doesn't with npm run dev - javascript

I got a task to do which is to create some forms with tailwindcss but When I try to launch : npm run build, it does't work. Could you help me?
npm ERR! code ELIFECYCLE
npm ERR! errno 9
npm ERR! widgets#1.0.0 dev: `tailwind build css/tailwind.css -o build/css/tailwind.css`
npm ERR! Exit status 9
npm ERR!
npm ERR! Failed at the widgets#1.0.0 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/andresbolivar/.npm/_logs/2022-01-21T16_59_01_550Z-debug.log
this is my package.json
{
"name": "widgets",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "tailwind build style.css -o /css/tailwind.css"
},
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer": "^10.4.2",
"postcss": "^8.4.5",
"tailwindcss": "^3.0.15"
},
"dependencies": {},
"description": ""
}

You need to install Tailwind CLI in order to execute tailwind commands:
# Using NPM?
npm install -D tailwindcss
# Using yarn?
yarn add tailwindcss -D
Also, it helps to check the error log (as mentioned in the message printed to your terminal) to find out a full stack trace of the error.

Related

When I run npm run build I get this error?

I am pretty new to this and pretty lost as well. I believe I switched up a lot of things which has me facing this problem at the moment. Ultimately, I am just trying to npm run build my React.js project so I could deploy it. But I run npm run build and I see this error:
my-blog git:(main) ✗ npm run build
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/rondon/code/my-blog/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/rondon/code/my-blog/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/rondon/.npm/_logs/2022-01-22T05_37_12_010Z-debug.log
What I understood from this is that I need to make a package.json file so I did that in my "my-blog" directory by running npm init. Cool, I do that and now I have a new package.json file in "my-blog" and I manually put in a "build": "react-scripts build" so I can run npm run build without getting an error saying I am missing a build script. This is how that package.json file looks now:
{
"name": "my-blog",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "react-scripts build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rmera1026/my-blog.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/rmera1026/my-blog/issues"
},
"homepage": "https://github.com/rmera1026/my-blog#readme"
}
I npm run build again and now get this:
my-blog git:(main) ✗ npm run build
> my-blog#1.0.0 build
> react-scripts build
sh: react-scripts: command not found
Lastly, I think I am having this problem because of how my file might be set up as well so here are how things are looking.
Your my-blog project has 2 directories. One is api, another one is client.
You have to build in your client directory, but you're outside of it. Change your directory to client and run npm run build
cd client && npm run build

Npm not running in terminal vite

What I typed: Npm run dev
Error:
npm ERR! Missing script: "dev"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\andre\AppData\Local\npm-cache\_logs\2021-11-12T04_58_51_898Z-debug.log
Json:
{
"name": "port",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"devDependencies": {
"vite": "^2.6.4"
},
"dependencies": {
"three": "^0.134.0"
}
}
If you could help thank you and if not thank you for reading this and taking your time out of your day
Goto you project directory by cd your-project-name.
run npm run dev command and try again (In your npm command "N" is capital).
and if not work please check below link (please refer green tick answer) :
How to resolve npm run dev missing script issues?

React npm run build is getting failed every time

when I am trying to build my react app. npm run build command is failed every time. When I use npm start command everything works fine,but I can not build the app with the command.
here is my error:
PS G:\self learning\react js\resort-reactjs> npm run build
> resort#0.1.0 build G:\self learning\react js\resort-reactjs
> react-scripts build
Creating an optimized production build...
Failed to compile.
static/js/main.b4300d14.js from UglifyJs
SyntaxError: Unexpected token: operator (>) [./~/contentful/dist/contentful.node.js:3909,0]
npm ERR! Windows_NT 10.0.18362
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\USER\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v12.18.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! resort#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the resort#0.1.0 build script 'react-scripts build'.
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 resort package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! react-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs resort
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls resort
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! G:\self learning\react js\resort-reactjs\npm-debug.log
in my package.json file everything is updated. my package.json file here. :
{
"name": "resort",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-icons": "^3.10.0",
"react-router-dom": "^5.2.0",
"react-scripts": "0.9.5",
"styled-components": "^5.1.1"
},
"devDependencies": {},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
The package.json file looks fine to me. I think it is a bug, or, at least, a poorly documented error. Try debug or just cleanup unwanted files that you dont need around the project and restart the build.

poblem with use the npm start in nodejs . 'nodemon' is not recognized as an internal or external command, operable program or batch file

i create a project in ubuntu and i run and deploy that , its worked fine .
now i change the operation system and a use the windows 10 and when i run this code npm start in vscode it show me this error :
> Store#1.0.0 start F:\Projects\Nodejs\Store
> nodemon server.js
'nodemon' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Store#1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Store#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\programmer\AppData\Roaming\npm-cache\_logs\2020-06-27T11_34_26_614Z-debug.log
i install the nodemon :
{
"name": "Store",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "nodemon server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"nodemon": "^2.0.4"
}
}
and download and install the nodejs in windows .
whats the problem ? how can i solve this problem ??
i solve the problem . i delete all node_module and install that again with npm install command .

Using external JS library in React server

I have to use a JS library called 'react-armor' here for my web project. So, created a React powered server as instructed here.
The server is up and running. But, in order to use the react-armor library, the code specifies to import the library into the project JS:
import { obfuscateClassNames } from 'react-armor';
*as in the readme.md tutorial of react-armor github
But, how could I use the package react-armor (examples given in the readme.md) into my react server? I mean, how to integrate the github repo to my server? Just using import something from 'react-armor', so where should react-armor exist?
Update 1:
Added react-armor dependency in server package.json file.
But, sudo npm install --save react-armor gives me errors.
npm http GET https://registry.npmjs.org/react-armor
npm http 404 https://registry.npmjs.org/react-armor
npm ERR! TypeError: Cannot read property 'latest' of undefined
npm ERR! at next (/usr/share/npm/lib/cache.js:687:35)
npm ERR! at /usr/share/npm/lib/cache.js:675:5
npm ERR! at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR! at /usr/lib/nodejs/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 3.13.0-87-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "react-armor"
npm ERR! cwd /home/local/unixroot
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! type non_object_property_load
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/local/unixroot/npm-debug.log
npm ERR! not ok code 0
Even after adding the dependency in package.json file, the import doesn't work.
This is my package.json in my react server folder:
{
"name": "react-tutorial",
"version": "0.0.0",
"private": true,
"license": "see LICENSE file",
"description": "Code from the React tutorial.",
"main": "server.js",
"dependencies": {
"react-armor": "elierotenberg/react-armor",
"body-parser": "^1.4.3",
"express": "^4.4.5"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "https://github.com/reactjs/react-tutorial.git"
},
"keywords": [
"react",
"tutorial",
"comment",
"example"
],
"author": "petehunt",
"bugs": {
"url": "https://github.com/reactjs/react-tutorial/issues"
},
"homepage": "https://github.com/reactjs/react-tutorial",
"engines" : {
"node" : "0.12.x"
}
}
Update 1:
It seems like some dependency errors here. But, is it possible to run this on Tomcat instead of NodeJS? Why does everyone recommend using NodeJS for ReactApp instead of Tomcat, despite React being a client side rendered JS lib?
If it's an NPM package, you would run npm install --save react-armor (--save if you want to add it to your down package's dependencies). It will download it and save it into a ./node_modules folder. Node will automatically look in that path (in addition to other preset locations) to find that module.
If it's not hosted on NPM, you can pull it in from GitHub by adding this to your package.json file.
"dependencies": {
"react-armor": "elierotenberg/react-armor"
}
Where the url is user/repo. You would still need to run npm install to actually download it.

Categories

Resources