Failed to load external module #babel/register while gulp - node.js

In my react project everything works fine on my vmware. But when I cloned the same app and ran gulp command I am getting this error during compilation saying
MacBook-Pro:Frontend1.0 apurvgandhwani$ gulp
[18:42:31] Failed to load external module #babel/register
[18:42:31] Requiring external module babel-register
[18:42:32] Using gulpfile ~/Frontend1.0/gulpfile.babel.js
[18:42:32] Starting 'build:watch'...
[18:42:32] Starting 'copy:assets'...
[18:42:32] Starting 'copy:vendors'...
Cleaned build/
Copied 12 asset entries.
[18:42:32] Finished 'copy:vendors' after 329 ms
[18:42:32] Starting 'copy:views'...
[18:42:32] copied views all files 19.75 kB
[18:42:32] Finished 'copy:views' after 77 ms
[18:42:32] Starting 'copy:public'...
[18:42:33] Finished 'copy:public' after 132 ms
[18:42:33] Finished 'copy:assets' after 540 ms
[18:42:33] Starting 'bundle:dll'...
DLL Bundled.
Hash: 45f26d608c690be6e6c5
Version: webpack 1.15.0
Time: 2181ms
Asset Size Chunks Chunk Names
dll.vendor.js 3.11 MB 0 [emitted] vendor
[18:42:35] Finished 'bundle:dll' after 2.21 s
[18:42:35] Starting 'bundle'...
Hash: 7457a3cd38cf5c991640
Version: webpack 1.15.0
Time: 508ms
Asset Size Chunks Chunk Names
server-bundle.js 37.3 kB 0 [emitted] main
-- server:watch bundled.
Hash: e4a95c52aac91b47f75c
Version: webpack 1.15.0
Time: 46339ms
Asset Size Chunks Chunk Names
main-bundle.js 20.1 MB 0 [emitted] main
-- client bundled.
[18:43:21] Finished 'bundle' after 46 s
[18:43:21] Starting 'start:server'...
Starting Node Server...
[18:43:21] Finished 'start:server' after 68 ms
[18:43:21] Starting 'watch:sync'...
[18:43:21] [nodemon] 1.11.0
[18:43:21] [nodemon] to restart at any time, enter `rs`
[18:43:21] [nodemon] watching: build/server-bundle.js
[18:43:21] [nodemon] starting `node --debug build/server-bundle.js`
Server Restarted: Reloading BrowserSync.
(node:6700) [DEP0062] DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. Please use `node --inspect` or `node --inspect-brk` instead.
[18:43:21] [nodemon] app crashed - waiting for file changes before starting...
[tessact: ] Proxying: http://localhost:4200
[tessact: ] Access URLs:
-------------------------------------
Local: http://localhost:3001
External: http://192.168.0.32:3001
-------------------------------------
UI: http://localhost:3002
UI External: http://192.168.0.32:3002
-------------------------------------
[tessact: ] Watching files...
[18:43:21] Finished 'watch:sync' after 262 ms
[18:43:21] Starting 'watch:assets'...
[18:43:22] Finished 'watch:assets' after 110 ms
[18:43:22] Finished 'build:watch' after 50 s
[18:43:22] Starting 'default'...
[18:43:22] Finished 'default' after 37 μs
webpack built e4a95c52aac91b47f75c in 26323ms
Hash: e4a95c52aac91b47f75c
Version: webpack 1.15.0
Time: 26323ms
Asset Size Chunks Chunk Names
main-bundle.js 20.1 MB 0 main
webpack: Compiled successfully.
[18:50:28] [nodemon] restarting due to changes...
[18:50:28] [nodemon] starting `node --debug build/server-bundle.js`
Server Restarted: Reloading BrowserSync.
[tessact: ] Reloading Browsers...
(node:6705) [DEP0062] DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. Please use `node --inspect` or `node --inspect-brk` instead.
[18:50:28] [nodemon] app crashed - waiting for file changes before starting...
Abort trap: 6
This is my package.json snippet
"dependencies": {
"#trendmicro/react-toggle-switch": "^0.5.5",
"animate.css": "^3.5.1",
"axis": "^0.6.1",
"babel-core": "^6.10.4",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"babel-preset-react-hmre": "^1.1.1",
I have followed a lot of threads but nothing seems to solve my case. What should I do to solve this? I already have babel-core instead of babel in my package.json which most of the solutions suggest.

I have solved it by downgrading the gulp version from 3.9.1 to 3.9.0. Looks like 3.9.1 is buggy.

This is just a warning that Gulp failed to load #babel/register but on the next line it successfully loaded the fallback module: babel-register
https://github.com/gulpjs/gulp/issues/1631
You could install the babel-core/register module to remove the warning, but it's not necessary.

You can remove the error with npm i -D babel-register (i = shorthand for install, D = shorthand for --save-dev)

Related

React App failed to compile after install

After running the install script, the server starts and serves a page displaying the same text after the 'Failed to compile line.'
I'm running Windows 10 and auto update just updated my pc today, right before I did the create-react-express install.
PS H:\mern-passport> npm start
> mern#1.0.0 start H:\mern-passport
> if-env NODE_ENV=production && npm run start:prod || npm run start:dev
> mern#1.0.0 start:dev H:\mern-passport
> concurrently "nodemon --ignore 'client/*'" "npm run client"
[0] [nodemon] 1.19.4
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching dir(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node server.js`
[0] API server now on port 3001!
[1]
[1] > mern#1.0.0 client H:\mern-passport
[1] > cd client && npm run start
[1]
[1]
[1] > mern#0.1.0 start H:\mern-passport\client
[1] > react-scripts start
[1]
[1] Starting the development server...
[1]
[1] Failed to compile.
[1]
[1] ./src/index.css (./node_modules/css-loader??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
[1] Error: Package exports for 'H:\mern-passport\client\node_modules\autoprefixer\node_modules\kleur' do not define a valid './colors' target
[0] Error: ENOENT: no such file or directory, stat 'H:\mern-passport\client\build\index.html'
[0] Error: ENOENT: no such file or directory, stat 'H:\mern-passport\client\build\index.html'
Seems to be an issue with autoprefixer latest version. I referred https://github.com/postcss/autoprefixer/issues/1328 and tried downgrading autoprefixer in my project and it works now.
Try:
npm install autoprefixer#9.8.0
Happy coding!
I also faced this problem. And it looks like a problem with autoprefixer version, so i changed the version.
npm install autoprefixer#9.8.0
I tried this, and it works perfectly.
I was running into this issue too. I installed yarn and created a new project with the npx create-react-app command and this fixed the issue.

Module not found: Error: Cannot resolve 'file' or 'directory' ../../

i am new for nodejs, in my hybris project, first i installed nodejs, run 'npm install','npm i cross-env' commands, when i run the command 'npm run hybris' from node_module folder, i got some errors can you provide any solution.
C:\Atlas_Insta\hybris\bin\custom\rodanandfields\rodanandfieldsstorefront\FE-Develop>npm run hybris
> RodanAndFields#1.0.0 hybris C:\Atlas_Insta\hybris\bin\custom\rodanandfields\rodanandfieldsstorefront\FE-Develop
> cross-env NODE_ENV=production gulp hybris-build
[15:29:07] Using gulpfile C:\Atlas_Insta\hybris\bin\custom\rodanandfields\rodanandfieldsstorefront\FE-Develop\gulpfile.js
[15:29:07] Starting 'clean'...
[15:29:07] Finished 'clean' after 128 ms
[15:29:07] Starting 'markupCompile'...
[15:29:08] Starting 'sass'...
[15:29:09] Finished 'sass' after 615 ms
[15:29:09] Starting 'js'...
[15:29:09] Finished 'js' after 129 ms
[15:29:09] Starting 'copy-img'...
[15:29:09] Finished 'copy-img' after 584 μs
[15:29:09] Starting 'copy-fonts'...
[15:29:09] Finished 'copy-fonts' after 597 μs
[15:29:09] Starting 'copy-api'...
[15:29:09] Finished 'copy-api' after 630 μs
[15:29:09] Starting 'read-templates'...
[15:29:09] Finished 'read-templates' after 1.87 ms
All templates written successfully!
[15:29:32] Version: webpack 1.15.0
Asset Size Chunks Chunk Names
app.js 1.19 MB 0 [emitted] app
app.map 9.63 MB 0 [emitted] app
ERROR in C:/Atlas_Repo/bin/custom/rodanandfields/rodanandfieldsstorefront/FE-Develop/web/webroot/WEB-INF/r2/fe-components/checkout/order-summary/order-summary.js
Module not found: Error: Cannot resolve 'file' or 'directory' ../../../../../_ui/frontend/js/analytics/analytics-eventmap-r2 in C:\Atlas_Repo\bin\custom\rodanandfields\rodanandfieldsstorefront\FE-Develop\web/webroot/WEB-INF/r2/fe-components\checkout\order-summary
# C:/Atlas_Repo/bin/custom/rodanandfields/rodanandfieldsstorefront/FE-Develop/web/webroot/WEB-INF/r2/fe-components/checkout/order-summary/order-summary.js 23:30-103
ERROR in C:/Atlas_Repo/bin/custom/rodanandfields/rodanandfieldsstorefront/FE-Develop/web/webroot/WEB-INF/r2/fe-components/checkout/checkout-form-billing/checkout-form-billing.js
Module not found: Error: Cannot resolve 'file' or 'directory' ../../../../../_ui/frontend/js/analytics/analytics-config-r2 in C:\Atlas_Repo\bin\custom\rodanandfields\rodanandfieldsstorefront\FE-Develop\web/webroot/WEB-INF/r2/fe-components\checkout\checkout-form-billing
# C:/Atlas_Repo/bin/custom/rodanandfields/rodanandfieldsstorefront/FE-Develop/web/webroot/WEB-INF/r2/fe-components/checkout/checkout-form-billing/checkout-form-billing.js 23:22-93
Which Hybris version are you using? I had a smilar problem with hybris 6.6. It worked for me after I switch to node v6.14.3 I was using a more recent node with a more recent npm version.
I found this version inside the npmancillary extension's folder
ext-content/npmancillary/resources/npm/node

angular2 universal is very unstable - [nodemon] app crashed - waiting for file changes before starting

I am finding the starter repo from angular class very very unstable or just on how I am using it. My code works locally hitting the same service as remote yet I get the below
I followed the rules
npm run build
npm start
The slightest error I get the below:
'Hash: 51619e5be8128fe9ed97eb75ce5c5bacf4f02ce1
Version: webpack 2.1.0-beta.22
Child
Hash: 51619e5be8128fe9ed97
Version: webpack 2.1.0-beta.22
Time: 18736ms
Asset Size Chunks Chunk Names
index.js 3.57 MB 0 [emitted] main
[320] ./src async 160 bytes {0} [built]
+ 544 hidden modules
Child
Hash: eb75ce5c5bacf4f02ce1
Version: webpack 2.1.0-beta.22
Time: 11670ms
Asset Size Chunks Chunk Names
index.js 33.5 kB 0 [emitted] main
+ 28 hidden modules
> universal-starter#2.0.0 start /var/test-starter
> npm run server
> universal-starter#2.0.0 server /var/test-starter
> nodemon dist/server/index.js
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /var/test-starter/dist/**/* src/index.html
[nodemon] starting `node dist/server/index.js`
Listening on: http://localhost:3000
EXCEPTION: Response with status: 200 Ok for URL: null
/var/test-starter/node_modules/zone.js/dist/zone-node.js:140
throw error;
^
Response with status: 200 Ok for URL: null
[nodemon] app crashed - waiting for file changes before starting...
How can this crash a server? I have to kill and restart.
I use angular2 n production without issue. angular2 universal is rather problematic.
How do I resolve gracefully? Or am I not serving in production properly?
The issue seems related with angular/zone.js based on your error.
Try to back to zone.js#0.6.21. If it works, try to locate the codes which cause the issue and reproduce it and post at here.
Since zone.js#0.6.22, there are some new issues, such as https://github.com/angular/zone.js/issues/448

Cannot start npm

I installed the seed app here: https://github.com/moizKachwala/Angular2-expressjs-mongoose-gulp-node-typescript
I'm trying to run npm start but the server is not being created and started.
I thought maybe this line "(node:16596) 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" was the issue and I found that on SO its was suggested to make sure you have latest npm which I do.
NOTE: The gulp script is supposed to create the dist folder where it will place all the js files but the dist folder is not being created so the gulp script is failing somewhere...
What else could it be?
c:\work\angular\pricecompare1>npm start
> angular2-express#1.0.0 start c:\work\angular\pricecompare1
> concurrent --kill-others "gulp watch" "gulp start"
[1] [09:35:54]
[0] [09:35:54] Requiring external module ts-node/register
[1] Requiring external module ts-node/register
[0] (node:16596) 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.
[1] (node:17124) 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.
[0] [09:35:55]
[0] Using gulpfile c:\work\angular\pricecompare1\gulpfile.ts
[1] [09:35:55] Using gulpfile c:\work\angular\pricecompare1\gulpfile.ts
[0] [09:35:55]
[0] Starting 'watch'...
[1] [09:35:55]
[1] Starting 'start'...
[1] [09:35:55]
[1] Finished 'start' after 1.88 ms
[1] [09:35:55] [nodemon] 1.10.0
[1] [09:35:55] [nodemon] to restart at any time, enter `rs`
[1] [09:35:55] [nodemon] watching: *.*
[1] [09:35:55] [nodemon] starting `node dist/server/server.js`
[0] [09:35:55] Finished 'watch' after 32 ms
[1] module.js:442
[1] throw err;
[1] ^
[1]
[1] Error: Cannot find module 'c:\work\angular\pricecompare1\dist\server\server.js'
[1] at Function.Module._resolveFilename (module.js:440:15)
[1] at Function.Module._load (module.js:388:25)
[1] at Module.runMain (module.js:575:10)
[1] at run (bootstrap_node.js:352:7)
[1] at startup (bootstrap_node.js:144:9)
[1] at bootstrap_node.js:467:3
[1] [09:35:55] [nodemon] app crashed - waiting for file changes before starting...
in your package.json file find start command and reference your server.js with correct directory
pricecompare1\dist\server\server.js

Could not connect to MongoDB : MEAN : Windows 10

Currently, I am trying to install MEAN on my windows 10 through cli (cmd).
I think i have completed all the installation part of MEAN and used npm to install all the packages as they were mentioned in tutorial and when I enter gulp (to run) it gives me this error :-
C:\...\nishant>gulp
Invoking gulp - development
[15:46:19] Using gulpfile ~\node\nishant\gulpfile.js
[15:46:19] Starting 'clean'...
[15:46:19] Finished 'clean' after 8.28 ms
[15:46:19] Starting 'default'...
[15:46:19] Starting 'webpack:build-dev'...
[15:46:19] Starting 'clean'...
[15:46:19] Starting 'less'...
[15:46:19] Starting 'sass'...
[15:46:19] Starting 'csslint'...
[15:46:19] Starting 'env:development'...
[15:46:19] Finished 'env:development' after 43 μs
[15:46:19] Starting 'devServe'...
[15:46:19] Finished 'devServe' after 96 ms
[15:46:19] Starting 'watch'...
[15:46:20] Finished 'watch' after 171 ms
[15:46:20] Finished 'clean' after 687 ms
[15:46:20] Finished 'less' after 692 ms
[15:46:20] Finished 'sass' after 418 ms
[15:46:20] csslint: 0 files lint free
[15:46:20] Finished 'csslint' after 399 ms
[15:46:20] [nodemon] 1.9.2
[15:46:20] [nodemon] to restart at any time, enter `rs`
[15:46:20] [nodemon] watching: *.*
[15:46:20] [nodemon] starting `node --debug server.js`
Debugger listening on port 5858
Error: connect ECONNREFUSED 127.0.0.1:27017
**Could not connect to MongoDB. Please ensure mongod is running and restart MEAN app.**
[15:46:27] [nodemon] clean exit - waiting for changes before restart
I tried to search for the answer but they were available for linux or mac but not for windows.
Looks like MongoDb is not running as a service. If memory serves, you may have to install the service manually. First check if it was installed: Start -> Run -> enter services.msc and look for it in the services list. If it's there, make sure it's running. If not, check out https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/ for steps on service installation.

Resources