npm SCSS not compiling - css

I have installed NPM correctly and written my main.scss file which I need to compile. My "package.json" file looks like this:
{
"name": "recreated-site",
"version": "1.0.0",
"description": "",
"main": "bootstrap.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"compile:sass": "node-sass sass/main.scss css/style.css"
},
"author": "",
"license": "ISC",
"dependencies": {
"bootstrap": "^4.4.1",
"sass": "^1.26.2"
},
"devDependencies": {
"node-sass": "^4.13.1"
}
}
Upon running the command "npm run compile:sass" I get this error message:
An output directory must be specified when compiling a directory
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! recreated-site#1.0.0 compile:sass: node-sass sass/main.scss css/style.css
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the recreated-site#1.0.0 compile:sass 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\Dell\AppData\Roaming\npm-cache_logs\2020-03-08T09_13_28_740Z-debug.log
I have no idea what I did wrong as I am new to SASS. Please help!

It seems you're running on Windows, which uses backslashes \ instead of forward slashes /.
Replace your blackslashes by forward slashes in your package.json like this :
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"compile:sass": "node-sass sass\main.scss css\style.css"
},
BTW, I'm not sure && and exit 1 works on Windows.

I had the same problem, I was using react-js.
After the changes in scss and compiled it again using npm command and it worked for me.

During defining scripts , In my case ,I just deleted The test line and only kept the compile:sass line. Below is my used scripts in JSON file:
"compile:sass":"node-sass sass/main.scss css/style.css -w"
}
After saving it , I open CMD at project location and run the command npm run compile:sass.
Hope this helps

Related

Can't build assets on deploy - Symfony 5/Encore/Ux

I have a Symfony 5 application, i'm using webpack Encore / Ux for the first time.
I'm facing difficulties with deployment, only the HTML is displayed at the URL ; the "build" directory is almost empty, it only contains "entrypoints.json" and "manifest.json". the assets aren't compiled.
When im running npm run build to compile the assets in production i have this message :
sh: encore: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! # build: encore production --progress
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the # build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The build script in the package.json doesnt work :
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
}
and i have no idea to where does this come from.
Would someone have something for this ?
i ran npm run build and it doesnt work, but it does in dev mode
Before deploying to production server you need to Compile Assets for Production on your dev server.
Then deploy only the built assets.
The process is documented here:
https://symfony.com/doc/current/frontend/encore/faq.html#how-do-i-deploy-my-encore-assets

Vercel deployment error | npm ERR! code E404

I'm trying to deploy my website on vercel it is a regular static portfolio website connected with a headless cms (graphql). I've previously deployed a website on vercel, had some errors but the errors were understandable and I managed to solve them all. However, when I try to deploy my web now it returns errors I cannot understand. I have googled and spent a few hours trying to fix the problems but it resulted in nothing. I'm really curious what the npm ERR! code E404 is.
Full error messages
Cloning github.com/Dylanyves/mac-yves (Branch: main, Commit: bf98fa3)
Cloning completed: 410.928ms
Installing build runtime...
Build runtime installed: 2.790s
Looking up build cache...
Build Cache not found
Installing dependencies...
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/find-up/-/find-upy-2%20px-4.1.0.tgz - Not found
npm ERR! 404
npm ERR! 404 'find-up#https://registry.npmjs.org/find-up/-/find-upy-2 px-4.1.0.tgz' is not in this 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! /vercel/.npm/_logs/2022-05-17T13_28_43_498Z-debug-0.log
Error: Command "npm install" exited with 1
package.json
{
"name": "next-portfolio",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"aos": "^2.3.4",
"graphql": "^16.5.0",
"graphql-request": "^4.2.0",
"html-react-parser": "^1.4.12",
"next": "12.1.6",
"react": "18.1.0",
"react-dom": "18.1.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"autoprefixer": "^10.4.7",
"eslint": "8.15.0",
"eslint-config-next": "12.1.6",
"postcss": "^8.4.13",
"tailwindcss": "^3.0.24"
}
}
You need to specify the Framework Preset in the Vercel's Build and Deployment settings.
Go through this documentation , this should help.

Firebase Cloud Functions deploy error javascript [duplicate]

This question already has answers here:
Cloud Functions deploy error during lint on Windows: "enoent ENOENT: no such file or directory"
(10 answers)
Closed 4 years ago.
I'm trying to deploy my cloud function firebase CLI, but there is an issue with my functions. I haven't changed any of my firebase cloud function settings. When I try to run firebase deploy --only functions, I get the following error:
npm ERR! errno -4058 npm ERR! syscall open npm ERR! enoent ENOENT: no
such file or directory, open
'F:\react\Fullstack-Hoffyevents-react-redux\event\%RESOURCE_DIR%\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!
C:\Users\wasif\AppData\Roaming\npm-cache_logs\2018-11-07T14_41_19_766Z-debug.log
Error: functions predeploy error: Command terminated with non-zero
exit code4294963238
This is a common issue on windows users
Go to your function folder and open firebase.json file
inside you will see something like this
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
}
change $RESOURCE_DIR with %RESOURCE_DIR% and that should work in your next deploy
you should have something like this
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"
]
}

Functions predeploy error: Command terminated with non-zero exit code1 [duplicate]

I was having issues with firebase deploy command recently. After firebase deploy command all others were being deployed except firebase (storage, database etc) So I decided to reinstall firebase to fix this situation but after reinstall my problem got bigger. Now none of them are deployed with the following error:
i deploying database, functions
Running command: npm --prefix $RESOURCE_DIR run lint
npm ERR! path C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\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! C:\Users\faruk\AppData\Roaming\npm-cache\_logs\2018-01-24T18_21_34_878Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code4294963238
After a bit research, I saw some topics about this which advice to change
$RESOURCE_DIR to %RESOURCE_DIR%
in windows systems (I am using windows 10 btw). So, I edited my firebase.json file which is in one upper level of my functions folder. like this. (I don't know if this is the right file that I should edit)
"database": {
"rules": "database.rules.json"
},
"functions": {
"predeploy": [
"npm --prefix %RESOURCE_DIR% run lint"
]
}
}
but after this edit, I started to get another error message like this.
i deploying database, functions
Running command: npm --prefix %RESOURCE_DIR% run lint
Usage: npm <command>
where <command> is one of:
access, adduser, bin, bugs, c, cache, completion, config,
ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
explore, get, help, help-search, i, init, install,
install-test, it, link, list, ln, login, logout, ls,
outdated, owner, pack, ping, prefix, profile, prune,
publish, rb, rebuild, repo, restart, root, run, run-script,
s, se, search, set, shrinkwrap, star, stars, start, stop, t,
team, test, token, tst, un, uninstall, unpublish, unstar,
up, update, v, version, view, whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
C:\Users\faruk\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#5.6.0 C:\Program Files\nodejs\node_modules\npm
Error: functions predeploy error: Command terminated with non-zero exit code1
Any advice is appreciated. Thanks in advance.
The error stems from the fact that you have a space somewhere in the path of your project ("Google Drive"):
C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json
Unfortunately, this is confusing the npm command line, and it's taking that as two arguments separated by that space.
Normally, I would expect to be able to place quotes around the whole thing to keep the space from being interpreted that way. So I tried this:
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
]
And it works for me.
I'll follow up with the Firebase team internally about this issue, as well as the fact that changes need to be made for Windows.
What happens actually is that in Windows, firebase.json contains the following by default:
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
Modify it to:
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
]
It worked for me, hope it works for you.
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
I remove that on firebase.json finally, it started to deploy again
For me, none of the above worked. Initially, on a fresh firebase-function install, I was getting error on non-zero exit code2. so I removed the functions directory, re-installed, but on the functions directory configuration step, I chose to say "no" to the add-lint step.
once I chose to not include lint, I got error non-zero exit code1.
from there checked my firebase.json file and looked at the predeploy script. because the deployment process was failing at this point, it was where I started. my firebase.json file looked like this:
{
"functions": {
"predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ]
}
}
for some reason I intuitively thought to remove the lint in the predeploy script. this fixed everything. Im on MacOS by the way..
This what work for me after change $RESOURCE_DIR to %RESOURCE_DIR% in firebase.json
{
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"
]
}
}
type this into your console ' firebase deploy --only hosting'. It worked for me
Try running npm install inside the functions folder of the project.
Maybe you are importing one or more node modules in index.ts that isn't installed, in this case you need to install it by running like:
npm install <somemodule> --save
I had the same problem in Windows. What I did was I copied all the files which were in functions folder and passed it to %RESOURCE_DIR% folder and then I run the Firebase deploy and it deployed successfully.
I fixed it: you must pay attention at another place
Do you see the error description
$ firebase deploy --only functions
=== Deploying to 'fix-firebase-functions'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions# lint C:\Users\vuduc\OneDrive\Tài liệu\Code tutotial practice\test\functions
> eslint .
C:\Users\vuduc\OneDrive\Tài liệu\Code tutotial practice\test\functions\index.js
37:16 warning Avoid nesting promises promise/no-nesting
42:13 error Expected catch() or return promise/catch-or-return
42:13 warning Avoid nesting promises promise/no-nesting
42:31 error Each then() should return a value or throw promise/always-return
✖ 4 problems (2 errors, 2 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions# lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions# lint 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\vuduc\AppData\Roaming\npm-cache\_logs\2020-06-01T14_38_16_060Z-debug.log
events.js:287
throw er; // Unhandled 'error' event
^
Error: spawn npm --prefix "%RESOURCE_DIR%" run lint ENOENT
at notFoundError (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess.cp.emit (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn npm --prefix "%RESOURCE_DIR%" run lint',
path: 'npm --prefix "%RESOURCE_DIR%" run lint',
spawnargs: []
Error: functions predeploy error: Command terminated with non-zero exit code1
error deploy cloud functions
You need to scroll up to see the error description, the line
functions predeploy error: Command terminated with non-zero exit code1
is just a general description that there is an error to fix before deploying.
This is what really needs attention, which instructions do you need to fix?
✖ 4 problems (2 errors, 2 warnings)
Pay attention here
This fixed it for me:
Go to "firebase.json" file in the root directory of the project
Remove everything inside "predeploy" in firebase.json, and it'll stop running the script which is causing issues.
"redeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
]
Use redeploy instead predeploy
For me, the issue was (I presume) because firebase couldn't find the script.
Didn't work:
{
"hosting": {
"predeploy": "predeploy.sh",
...
}
Running command: predeploy.sh
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn predeploy.sh ENOENT
at exports._errnoException (util.js:1020:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
Error: hosting predeploy error: Command terminated with non-zero exit code1
Did work: (note the ./)
{
"hosting": {
"predeploy": "./predeploy.sh",
...
}
When Using VS code ,open folder of Firecast (this helps open firebase.json of Resource Directory ) In firebase.json change the code of file to this:
{
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"
]
}
}
In my case I created a function to print logs, something like this:
function log(tag: string, value: any) {
console.log(tag, JSON.stringify(value));
}
When I add async in front of it, it starts exploding the build :)
I solve this by re-initiating firebase init, then not selecting to use eslint. Deploy worked after that.
This can also happen if you dont choose a blaze plan from firebase. basically deployment of cloud functions require a blaze plan activated
I'm on mac and since I moved my firebase project to another directory/laptop, I had this exact issue.
I resolved my issue by just re-initializing my firebase project.
firebase init
Be careful though. Since most of your files already exist, it might want to override them. Just say no to all override questions. Unless of course all your code is pushed to the firebase console ... which it should be 😋
"predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ]
I remove that on firebase.json finally, it works for me.

grunt command not found though installation seems good

I'm working with grunt 0.4 and Ubuntu 12.
I followed the installation process from the grunt.js site and have these results:
npm list -g | grep grunt
grunt-cli#0.1.9
I tried with the simplest package.json
{
"name": "test",
"version": "0.0.0",
"private": true,
"devDependencies": {
"grunt": "~0.4.1"
},
"engines": {
"node": ">=0.8.0"
}
}
Then npm install seems to get the work done:
npm list | grep grunt
grunt#0.4.1
But if I try grunt --help I have a message saying that the grunt command was not found...
Please does someone have an idea ?
Nevermind, I uninstalled grunt-cli, then reinstalled it and the problem disappeared...

Resources