Grunt error SailsJS when lifting with --no-frontend - gruntjs

I have a Sails Api which the first time boots like a charm.
Press CTRL + C to stop it and then try to start it again. It works, BUT,
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
Aborted due to warnings.
Running "clean:dev" (clean) task
Warning: Cannot delete files outside the current working directory.
------------------------------------------------------------------------
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `folderthingy` ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R 501 folderthingy
Well, I check it all, and the folder just is my own and has enough rights. I also put up a 777 for testing purposes but this didn't change a thing.
Then, I decided to clear out all the contents of the .tmp folder and try to boot again. This worked like a charm, .tmp got filled again, and when I stopped the server, tried to reboot it, I got the exact same error message again!
I'm booting with the --no-frontend option, so in fact I don't understand why it even wants to load grunt.
Why is this happening? What's going wrong here?

Why it happens is still not known to mankind, but I fixed it with removing the Gruntfile.

Fixed this by following below steps :
File path in your sails app -> tasks/config/sync.js
// 1. Install it as a local dependency of your Sails app:
// ```
// $ npm install grunt-sync --save-dev --save-exact
// ```
//
//
// 2. Then uncomment the following code:
//
// ```
// // Load Grunt plugin from the node_modules/ folder.
// grunt.loadNpmTasks('grunt-sync');
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Note: Work for Warning "sync:dev" not found

If you are using Linux, try doing sudo sails lift, you can have problems with permissions (happened to me). If Windows - check that no file manager or some other program is blocking the .tmp folder (also happened to me when I opened the folder in Total Commander).
In any case, since you don't use frontend, you can simply remove some of the grunt tasks (in the folder tasks/ you have README.md which explains which tasks are run in which case) or all of them (see documentation) and you won't have the problem.

i also got this error-
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
Aborted due to warnings.
Running "sass:dev" (sass) task
> error: Looks like a Grunt error occurred--
>
> error: Please fix it, then **restart Sails** to continue running tasks
> (e.g. watching for changes in assets)
>
> error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `/Users/siyaram.malav/Desktop/repo/project1/.tmp` ?
this error came because it could not find the sass module.And ran following command
sudo gem install sass
it worked for me.
In your case, try running sudo gem install clean command.
it should work.
thanks.

I had the same problem while following this tutorial:
https://www.youtube.com/watch?v=ZE7ye2G_H9Q&index=4&list=PLf8i4fc0zJBzLhOe6FwHpGhBDgqwInJWZ
I created a "linker" folder since that's what the guy did, which then prompted me with the error. It looks like he's using an older version of SailsJS since he runs into no errors.
Did you by any chance create a new folder in the assets folder? If you did, the problem is that grunt isn't able to run tasks on the specific folder since it's not linked with the rest of the assets folders and files. Try placing all newly created files within already existing folders and trying again. This worked for me.

Related

Problem with yarn dependency using the rhino R package

I am trying the new R package rhino from the Appsilon team to build shiny apps.
Running on a Windows10 laptop I installed the dependencies node.js and yarn as described in this tutorial.
Here is the output of rhino::diagnostics() :
Windows 10 x64 build 19042
R version 4.1.0 (2021-05-18)
rhino: 1.0.0
node: v16.15.0
yarn: 1.22.15
Running rhino::build_sass() gives me this error:
yarn run v1.22.15
$ sass --no-source-map --style=compressed root/app/styles/main.scss:root/app/static/css/app.min.css
Error reading root\app\styles\main.scss: no such file or directory.
error Command failed with exit code 66.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error:
! System command 'yarn' exited with status 66.
i If you can't use Node.js and yarn, try using sass: 'r' configuration.
Run `rlang::last_error()` to see where the error occurred.
I am puzzled by the paths in the call to "sass" that start with "root/app". My app is located in my home directory:
"C:/Users/XXX/Documents/workspace/rhino_dummy"
Is it possible that these paths are wrong in the call?
Luckily, the suggested alternative with the deprecated libsass interpreter works for the sass example in the tutorial. It would be nice to have node.js with sass working on Windows10 for future more complex apps.
Edit 1, after Kat's comment
Thanks Kat for the quick feedback. I added sass via yarn add sass and tried again same error:
> rhino::build_sass()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ sass --no-source-map --style=compressed root/app/styles/main.scss:root/app/static/css/app.min.css
Error reading root\app\styles\main.scss: no such file or directory.
error Command failed with exit code 66.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error:
! System command 'yarn' exited with status 66.
i If you can't use Node.js and yarn, try using sass: 'r' configuration.
Run `rlang::last_error()` to see where the error occurred.
The warning is coming from the pckage.json file that was created by calling yarn inside my R project folder. It has only minimal content:
# package.json
{
"dependencies": {
"sass": "^1.51.0"
}
}
Out of curiosity, I tried to compile the javascript example, also failed with very similar error regarding folder paths:
> rhino::build_js()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ webpack
assets by status 0 bytes [cached] 1 asset
ERROR in main
Module not found: Error: Can't resolve 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js' in 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node'
resolve 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js' in 'C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node'
using description file: C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration using description file: C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\package.json (relative path: ./root/app/js/index.js)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js.wasm doesn't exist
as directory
C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root\app\js\index.js doesn't exist
webpack 5.69.0 compiled with 1 error in 162 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error in `system_yarn()`:
! System command 'yarn' exited with status 1.
Run `rlang::last_error()` to see where the error occurred.
For Node.js functions to work on Windows 10, you'll need to enable Developer Mode on your system as mentioned in our How-to: Use Rhino on Windows article. This is necessary for symbolic links to work on Windows (and the .rhino/node/root file is a symbolic link to the root of the project).
After you do that, delete the .rhino/node directory from your project, or run rhino:::add_node(clean = TRUE) in the root of your project.
Workaround
This answer is only a workaround, if you cannot enable developer mode on windows (see Kamil Zyla's post for more information).
It looks like the folder name "root" in the error messages is a broken variable.
The folder ...\workspace\rhino_dummy\.rhino\node\root does not exist, but the substructures do exit:
app\styles\main.scss
app\js\index.js
...\workspace\rhino_dummy\.rhino\node
Fix step1
I tried my luck and created the folder "root": C:\Users\XXX\Documents\workspace\rhino_dummy\.rhino\node\root
copied rhino_dummy\app\styles\main.scss to rhino_dummy\.rhino\node\root\app\styles\main.scss
copied rhino_dummy\app\js\index.js to rhino_dummy\.rhino\node\root\app\js\index.js
running rhino::build_sass() and rhino::build_js() now worked!
rhino::build_sass()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ sass --no-source-map --style=compressed root/app/styles/main.scss:root/app/static/css/app.min.css
Done in 0.45s.
rhino::build_js()
yarn run v1.22.15
warning ..\..\package.json: No license field
$ webpack
asset app.min.js 470 bytes [compared for emit] [minimized] (name: main)
runtime modules 670 bytes 3 modules
./root/app/js/index.js 113 bytes [built] [code generated]
webpack 5.69.0 compiled successfully in 846 ms
Done in 2.58s.
Fix step2
copy results back to "static" folder, where they are expected by shiny/rhino
copy rhino_dummy\.rhino\node\root\app\static\css\app.min.css to rhino_dummy\app\static\css\app.min.css
copy \rhino_dummy\.rhino\node\root\app\static\js\app.min.js to \rhino_dummy\app\static\js\app.min.js
launch the app via shiny::shinyAppDir(".")
click the button from the tutorial ;-)
Edit1
Checking the github repo of rhino
SASS
definition of build_sass()
calling yarn("build-sass")
definition of build-sass
showing hard-coded root/app/styles/main.scss
JS
definition of build_js()
calling yarn("build-js")
definition of "webpack" build-js also showing hard-coded "root" in file paths

how to solve Firebase CLI error on start up

when I open firebase CLI I get this error :
Let's make sure your Firebase CLI is ready...
undefined:1
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at ChildProcess.<anonymous> (C:\snapshot\firepit\welcome.js:115:27)
at ChildProcess.emit (events.js:311:20)
at maybeClose (internal/child_process.js:1021:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Socket.emit (events.js:311:20)
at Pipe.<anonymous> (net.js:668:12)
I am using windows 10 pro
The comment on the original question was the solution for me. My "Downloads" folder is hosted on D: and the installer assumes C:
(how to solve Firebase CLI error on start up)
A solution that helped me after transferring the exe to C has failed, is deleting the folder:
C:\Users\{YOUR_PROFILE_NAME}\.cache\firebase
Hope this helps anyone
That is nothing to worry about, it only appears because the CLI by default assumes it is in the C directory.
So, copying the CLI exe to any other directory would show this message but, you can still use all the CLI functionalities as you wish.
Like what I did here using firebase init
The solution :
leave the exe name as: "firebase-win.exe" and you can move it to whatever folder you want
The detailed explanation:
i moved the executable i downloaded ("firebase-tools-instant-win.exe") to folder: c:\firebase\bin
and it works without any error,
but for some reason if i rename the exe file to something like: "firebase.exe" or "fbcli.exe" it will throw the json error and will not download the .cache folder correctly
but if i rename the exe name to: "firebase-win.exe" it works no matter what folder i put it in,
when checking C:\Users{YOUR_PROFILE_NAME}.cache\firebase\runtime\shell.bat
if the exe name is: "firebase.exe" (Not working) then the content is:
#echo off
"C:\firebase\bin\firebase.exe" C:\Users\{YOUR_PROFILE_NAME}\CACHE~1\firebase\runtime\shell.js %*
if the exe name is: "firebase-win.exe" (working) then the content is:
#echo off
"C:\firebase\bin\FIREBA~1.EXE" C:\Users\shaybc\.cache\firebase\runtime\shell.js %*
so i simply left the exe name: "firebase-win.exe"
valid names worked for me:
fireb-win.exe
firebase-win.exe
firebase-w.exe
fire-base.exe
fbcli-win.exe
...
Install Firebase using npm:
npm install firebase
source:
https://firebase.google.com/docs/web/setup
I got this warning as well, but when I tried to init, serve, and deploy, it worked just fine. Good luck!

EPERM: operation not permitted, unlink C:\Users

I am using Meteor 1.4.3.2 on a windows7 dev environment.
A Meteor application I have developed has been great for 6+ months but I have caused a problem by removing modules and apparently something I should not have.
Something outside the application folders (sym-link pointing into \AppData\Local.meteor.. somewhere) is missing/wrong, I think.
All other projects are fine, except this one.
All of my backup copies for this project are failing now too, including fresh clone from repo.
No 'meteor' commands will in this project, or it's backup copies, so 'meteor reset' is not an option.
The error is:
C:\Users\muser\iNotice>meteor
C:\Users\muser\AppData\Local\.meteor\packages\meteor-tool\1.4.3_2\mt-os.windows.
x86_32\dev_bundle\lib\node_modules\meteor-promise\promise_server.js:190
throw error;
^
Error: EPERM: operation not permitted, unlink 'C:\Users\muser\iNotice\.meteor\lo
cal\dev_bundle'
at Error (native)
at Object.fs.unlinkSync (fs.js:932:18)
at exports.makeLink (C:\tools\cli\dev-bundle-links.js:20:8)
at [object Object]._.extend.ensureDevBundleLink (C:\tools\project-context.js
:1476:7)
at [object Object]._.extend._readFile (C:\tools\project-context.js:1410:10)
at new exports.ReleaseFile (C:\tools\project-context.js:1360:8)
at C:\tools\cli\main.js:898:22
Any suggestions on best approach to fix the application?
Thanks very much for your time and expertise.
Pick one of the following:
You can delete the content of your .meteor/local folder (repopulated next time you run > meteor)
Or call meteor as an admin
Or remove the read-only access on the dev_bundle folder (but Windows sets it back to read-only from time to time)
Thanks #n3squik!
Here are the actions I took which fixed my problem.
Remove folders:
C:\Users\muser\testApp\.meteor\local\dev_bundle*\*
C:\Users\muser\AppData\Local\.meteor\packages\meteor-tool\1.4.0-1\*
Ran:
C:\Users\muser\testApp> meteor run
The application started up and all seems good.
Thanks again Stack.

No metadata files found for isopack

whenever i run any meteor command like
meteor run android-device
it is giving this error
C:\Users\abc\AppData\Local.meteor\packages\meteor-tool\1.4.2_3\mt-os.windows.x86_32\dev_bundle\lib\node_modules\meteor-promise\promise_server.js:190
throw error;
^
Error: No metadata files found for isopack at:
/C/Users/abc/AppData/Local/.meteor/packages/meteor-tool/1.3.2_4
at Isopack._loadUnibuildsFromPath (C:\tools\isobuild\isopack.js:900:13)
i have tried to uninstall and reinstall meteor again, also tried to update version but fails completely.

Why does grunt.loadNpmTask('grunt-contrib-jshint') trigger an error in Sails.js?

This seems pretty straightforward, but I can't seem to debug this error. I've added this code to my Sails API as /tasks/config/jshint.js
module.exports = function(grunt) {
console.log(1);
grunt.config.set('jshint', {
files: {
src: ['api/services/*.js', 'api/policies/*.js', 'api/controllers/*.js']
}
});
console.log(2);
grunt.loadNpmTask('grunt-contrib-jshint');
console.log(3);
};
Now, when I execute any grunt task, I get an error message (but the older tasks still execute successfully).
C:\dev\fo-rest-api>grunt aglio
1
2
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function
Running "aglio:your_target" (aglio) task
...
Done, without errors.
When I run the jshint task, I get the same loading error and the task is aborted.
C:\dev\fo-rest-api>grunt jshint
1
2
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function
Warning: Task "jshint" not found. Use --force to continue.
Aborted due to warnings.
C:\dev\fo-rest-api>
A few other notes:
Using --force only changes the wording of the error message.
grunt-contrib-jshint seems to be successfully installed in /node_modules (I deleted everything and re-ran npm install to be sure.
I'm running this on Windows, if that matters. I've tried opening the command line as both a normal user and as administrator.
I tried commenting out the loadNpmTask line to see if sails would load it automatically, but still got Warning: Task "jshint" not found.
Thanks for any clues you might have.
The answer was pretty straightforward. I somehow deleted the s at the end of grunt.loadNpmTasks. When I added it back, everything worked well.
I wish there was some sort of syntax highlighting that for common packages like grunt that would identify this kind of typo...

Resources