Node Application shows No Gruntfile (grunt.js, Gruntfile.js, Gruntfile.coffee) found - node.js

After I git push it onto heroku with grunt build pack, it shows the following errors:
-----> No Gruntfile (grunt.js, Gruntfile.js, Gruntfile.coffee) found
But by checking git, i can sure that there is a gruntfile.js exist and it is successful by running grunt on my local side.
It caused my application cannot be used and have the following result in the console:
Uncaught SyntaxError: Unexpected token < /build/js/dist.min.js:1
Anyway to solve it? Thanks!

Change the filename to Gruntfile.js (with a capital G).

Fixed by modyfy the content of grunt file and package.json

Related

Can't create a react native empty project, app.json not found

I am currently trying to get started with react native.
I set up the development environment referring to the documentation, but can't even pass the first step and create an empty project.
I am on Windows 11, Node 16.15.1, and NPM 8.12.2
I keep getting the following error when trying to init react-ative project with expo init awesomeProject
Error downloading and extracting template package: Error: npm exited with non-zero code: 1
× Something went wrong while downloading and extracting the template.
Can't read JSON file: D:\crna\awesomeProject\app.json
└─ Cause: Error: ENOENT: no such file or directory, open 'D:\crna\awesomeProject\app.json'
Does anyone has a suggestion ?
Don't really know what is the problem but i found a soluion that might help other people in the same situation as me! like said here just run in CMD instead of GitBash
Use sudo if on linux. And maybe Admin on windows.

Heroku build error "Extracting tar content of undefined failed"

I have a react-nodejs app which builds fine locally but when pushing to Heroku it returns an error:
remote: error https://registry.yarnpkg.com/#privacyresearch/libsignal-protocol-protobuf-ts/-/libsignal-protocol-protobuf-ts-0.0.8.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, open '/tmp/yarncache.96jam/v6/npm-#privacyresearch-libsignal-protocol-protobuf-ts-0.0.8-5f8c6f70b1f50805b06fa38d81c0994f82e8562f-integrity/node_modules/#privacyresearch/libsignal-protocol-protobuf-ts/LICENSE'"
Here's my package.json file.
I read through several related questions and it seems like the root cause might be related to having a github url in the package.json. Given that it is also a hard dependency for me, I don't know how to proceed. Any help will be appreciated!
Try yarn install --network-concurrency 1
And try adding a .yarnrc file to the project with following line: network-concurrency 1

Module not found: Error: Can't resolve '../aws-exports' (React-Native Expo Web)

I've developed an app which works perfectly when I run it through expo start --tunnel and then the w key for expo web.
In order to deploy it, I have tried to use the Amplify console, which seemed to work. However, while deploying the app, it has halted with the following messages:
2020-02-10T16:39:57.658Z [WARNING]: <s> [webpack.Progress] 70% building 41/59 modules 18 active /root/.nvm/versions/node/v10.16.0/lib/node_modules/expo-cli/node_modules/babel-loader/lib/index.js??ref--5-oneOf-2!/codebuild/output/src261112836/src/gmpmgr2v/node_modules/expo/build/Notifications/ExponentNotifications.web.js
2020-02-10T16:39:57.661Z [WARNING]: [16:39:57] web Failed to compile.
2020-02-10T16:39:57.661Z [WARNING]: [16:39:57]
2020-02-10T16:39:57.662Z [WARNING]: [16:39:57] Module not found: Error: Can't resolve '../aws-exports' in '/codebuild/output/src261112836/src/gmpmgr2v/src/modules'
2020-02-10T16:39:57.662Z [WARNING]: [16:39:57] Set EXPO_DEBUG=true in your env to view the stack trace.
2020-02-10T16:39:57.673Z [ERROR]: !!! Build failed
2020-02-10T16:39:57.674Z [ERROR]: !!! Non-Zero Exit Code detected
2020-02-10T16:39:57.674Z [INFO]: # Starting environment caching...
2020-02-10T16:39:57.674Z [INFO]: # Environment caching completed
I don't believe there is an issue with my aws-config file, otherwise I would not be able to run it through the expo start --tunnel command.
I believe it is probably not copying aws-config.js to somewhere it should while creating the build.
Has anyone had this problem as well, or know how to address it?
This file is .gitignore and hence it will not show up in your CI.
I was following the documentation to get started with a React app, and the documentation had a different path for the configuration than what the Expo app init command created by default.
So to fix this, I had to change the import command in my App.js file from:
import config from './aws-exports'
to
import config from './src/aws-exports'
For some reason, in the case of this app, a relative reference to aws-exports file did not work, by using the two dots. Changing to a direct path did the job.

Deploying NodeJS/Babel/Grunt app on Heroku

I'm trying to deploy my project on Heroku. I've been able to heroku open the app and see it but I get a 404 on my bundle.js. The app is on github here. The app is on heroku here.
I've tried making sure my dependencies are all there regarding babel, babelify, grunt, etc. But I must be still missing something.
I don't get any errors after my git push heroku but I still get my 404.
I am able to recreate this locally as well. This is what I get when I run your postinstall script code:
$ npm run postinstall
> ncps-mms#0.0.0 postinstall ncps-mms
> gulp transpile --gulpfile client/gulpfile.babel.js
[00:18:43] Requiring external module babel-register
[00:18:43] Working directory changed to ncps-mms/client
(node:30276) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[00:18:43] Using gulpfile ncps-mms/client/gulpfile.babel.js
[00:18:44] Starting 'transpile'...
Error: Cannot find module './controllers/members-detail-controller' from 'ncps-mms/client/src'
[00:18:44] Finished 'transpile' after 184 ms
I see this error:
Error: Cannot find module './controllers/members-detail-controller' from 'ncps-mms/client/src'
The members-detail-controller is missing - See: https://github.com/gh0st/ncps-mms/tree/master/client/src/controllers.
If I comment out the following lines, https://github.com/gh0st/ncps-mms/blob/master/client/src/app.js#L4 and https://github.com/gh0st/ncps-mms/blob/master/client/src/app.js#L15 then run npm run postinstall again, the gulp tasks run without errors. I am then able to start the server without the 404's on bundle.js.

node jitsu cannot find local modules

I have an application successfully working locally so I know the code works. However when I go to deploy to node jitsu I get an error that it cannot find a local module. Here is what I have:
File Setup:
/index.js
/config/config.js
index.js
var cfg = require('./config/config.js');
When trying to deploy node jitsu is giving me an error:
Error: Cannot find module './config/config.js'
Since all this code works locally I do not believe this is a coding issue. I am under the impression that local modules do not need to be included in package.json but perhaps they do for node jitsu? I read their documentation but cannot find anything special for local modules.
Thanks!
Local modules like this should work properly.. so long as you don't have it in .gitignore or .npmignore.
Modules in the node_modules directory require that you add it to the bundledDependencies array in your package.json file.
An easy way to check for whether the file is included in your deploy is to run tar -tf $(npm pack).
I had this exact same error on deploy, but caused by a different root cause. In case anybody stumbles into the same problem:
File Setup:
/public/Data/TargetData.js
app.js require statement:
var target = require('./public/data/TargetData.js');
My local Mac OSX environment allowed the capitalization difference of /data/ vs. /Data/ - the Nodejitsu server did not.

Resources