"Module build failed..." in Laravel Mix - npm

I did not change anything in app.scss, but when I run npm run watch I get the following errors:
error in ./resources/sass/app.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Unsupported operation: Cannot extract a file path from a URI with a fragment component
# ./resources/sass/app.scss 2:14-254
Asset Size Chunks Chunk Names
/js/app.js 2.46 MiB /js/app [emitted] /js/app
ERROR in ./resources/sass/app.scss
Module build failed (from ./node_modules/css-loader/index.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js):
undefined
^
Join(null, "variables"): part 0 was null, but part 1 was not.
#import 'variables';
^^^^^^^^^^^
stdin 2:9 root stylesheet
in C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\resources\sass\app.scss (line 2, column 9)
at runLoaders (C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\node_modules\webpack\lib\NormalModule.js:30
at C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\node_modules\loader-runner\lib\LoaderRunner.js:364:11
at C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\node_modules\loader-runner\lib\LoaderRunner.js:230:18
at context.callback (C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\node_modules\loader-runner\lib\Loader
13)
Any help appreciated.

Finally found the issue. It is related to dart-sass being used instead of node-sass with laravel-mix v4.x.x.
Turns out something related to dart-sass or laravel-mix does not work well with paths containing a '#' symbol. In your case, your app is located at C:\Users\TAQI VAHEED\Desktop\#Coding\resPro and the #Coding folder is creating the error.
Either move your app somewhere else without a '#' symbol in the path OR enable node-sass again by following the steps from laravel-mix 4.0.0 release notes:
you can manually switch back to node-sass, like so:
npm install node-sass
mix.sass('resources/sass/app.sass', 'public/css', {
implementation: require('node-sass')
});

in your webpack.mix.js write the code
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css');

Related

After make an npm update the console shows Error: Module not found: Error: Can't resolve 'angular2-moment'

I was trying to install jquery on my Angular project and after write some jquery dependency on package.json doc and type npm update, the console says Error: Module not found: Error: Can't resolve 'angular2-moment'.
Error occurs in the template of component RegisterComponent.
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
× Failed to compile.
✔ Browser application bundle generation complete.
Initial Chunk Files | Names | Raw Size
main.js | main | 83.62 kB |
runtime.js | runtime | 6.51 kB |
4 unchanged chunks
Build at: 2023-01-10T02:39:00.432Z - Hash: 2a1b1b37176d6913 - Time: 536ms
./src/app/app.module.ts:7:0-47 - Error: Module not found: Error: Can't resolve 'angular2-moment' in 'C:\Users\xxxxxx\Desktop\Proyectos IT\registro_cintas\client\src\app'
Error: src/app/app.component.html:6:34 - error NG8002: Can't bind to 'routerLink' since it isn't a known property of 'a'.
6 <a class="link-home" [routerLink]="['/home']">
continue...
~~~~~~~~~~~~~~~~~~~~~~~~
I tryed installing ngx-moment, angular2-moment again or uninstalling this last one algo I erase the entire folder and made a git clone from the last working commit but nothing, I think the angular2-moment it's not compatible with my Angular version but I don't know what to do.

npm babel ES2015: Getting command lines in the converted/output JS file

I've installed npm (v4.4.4) and babel (v6.24.0) and babel preset 2015.
All running OK when converting ES6 JS to ES5...except a couple of oddities. Maybe someone can see what this newbie is doing wrong.
1) I run babel from npm (see below) which runs OK. I added some script entries into package.JSON to make it work.
But, UNWANTED oddity...npm inserts the commands into the output JS file. (See below) Is there an npm option to say, don't put the command in the output file.
Yet....if I copy input.JS to the folder with babel.cmd and run it there, I get a clean output.JS. So it looks like npm is inserting the command lines into the output.js file.
How do I prevent the npm commands being written to output.js. (Obviously I don't want to have my JS files having to share a folder with the .bin files)
2) When I type > babel on the command line in my project folder, I get:
babel: not a command.
I EXPECT THIS. After all, I have not added node_modules/.bin to my PATH env var. Yet every YouTube video I watch about npm and babel, it works. How? No one seems to edit the PATH env var. Am I missing something?
Thanks
Milton.
INPUT JS FILE (input.js)
class House {
constructor(v) {
this.name = v;
}
}
OUTPUT JS (TRANSPILED) FILE (output.js) Note 1st 2 lines below...
> milton#1.0.0 babel C:\Projects1\01InstallReact4Dev
> babel.cmd "--presets" "es2015" "input.js"
"use strict";
function _classCallCheck(instance, Constructor)
{ if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var House = function House(v) {
_classCallCheck(this, House);
this.name = v;
};
PACKAGE.JSON
"scripts": {
"babel": "babel.cmd",
"babelv": "babel.cmd -V",
"babelh": "babel.cmd -help"
}
COMMAND
> npm run babel -- --presets es2015 input.js > output.js
Thanks Again.
Milton.
You're redirecting the output of stdout to the file output.js, this includes everything that is displayed. Instead of using the stdout output of babel you can use the --out-file or -o option. This will write the output to the specified file instead of printing it to stdout (see Compile Files).
Your command would be:
npm run babel -- --presets es2015 input.js --out-file output.js
When I type > babel on the command line in my project folder, I get: babel: not a command.
You don't have node_modules/.bin/ in your shells PATH. You could add it or run it directly with ./node_modules/.bin/babel. But this is not necessary if you do it in an npm script, because npm will automatically look into node_modules/.bin/ without it being in your PATH. In this case you could define the following script:
"scripts": {
"build": "babel --presets es2015 input.js --out-file output.js"
}
And then you can simply run:
npm run build
If you'd like to transpile more than one file you should use --out-dir instead of --out-file otherwise they will be concatenated into one file. See also Compile Directories

How to debug js in browserify

I have using browserify for new project. It works really well so far.
I have one big issue though. How can I debug each js file separately. It bundles all the files together and points to bundle if error occurs.
I am using chrome and source maps but it doesn't really help in debugging.
Any ideas?
Update: More info:
I'm using this command in package.json
"start": "watchify scripts/main.js -o scripts/bundle.js --debug",
and getting errors as shown above which is not ideal.
I believe my source maps are on?
I'm not exactly sure how you are using the command line tool for browserify without any code, but you you should be able to utilize debug.
--debug -d Enable source maps that allow you to debug your files
separately.
browserify main.js -o bundle.js --debug
For more info on the CLI tool you can look here - https://github.com/substack/node-browserify#usage
Edit After a bit more digging on this - the issue specifically being hit here is a ParseError - which means that Browserify is never actually getting to the proper debug stage. Hadn't really thought it through, but this made perfect sense.
In order to test this - I create two simple files:
a.js
module.exports = function(a) {
return a;
}
main.js
var a = require('./a.js');
console.log(a("something"));
I then ran browserify using watchify with an npm script:
"start": "watchify main.js -o bundle.js --debug"
Using the script in a browser, and everything worked great - it logged to console as expected. I then edited a.js with a typo:
a.js
module.exports = function(a) {
return a---
}
The browser and watchify threw the error shown above: path/to/file/a.js:3 ParseError: Unexpected Token.
Browserify is not able to compile the file properly, so it's throwing an error. You should be seeing this in the console during the build.
To test that the --debug flag works as expected, I modified the code again:
a.js
module.exports = function(a) {
return a('something');
}
The expectation here would be a TypeError since the function now expects a to be a function.
The console in the browser now displays:
Uncaught TypeError: a is not a function __________ a.js:2
Fix your parse issues, and browserify --debug will once again start behaving as expected.

show error line and file when compile coffeeify

How to make browserify show error line and file on compile:
browserify -t coffeeify mainPage_browserify.coffee > main.js -d
The current output don't give this information. So it is hard to debug:
⏎
Error: Cannot find module 'throw' from '/allProjectsPath/project/public/javascripts/map'
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:50:17
at process (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:119:43)
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:128:21
at load (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:60:43)
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:66:22
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:21:47
at Object.oncomplete (fs.js:107:15)
❯ browserify --version ⏎
5.12.1
I was interested in this by myself, so I had a quick peek into source code and run debugger. It looks like that errors from transforms are basically swallowed when using command line browserify.
Errors from coffeeify are passed using event emitter on the stream...
https://github.com/substack/coffeeify/blob/master/index.js#L35
These are handled by Browserify only if the bundle call was made with callback present...
https://github.com/substack/node-browserify/blob/master/index.js#L619
Unfortunately callback is not passed when running the command line...
https://github.com/substack/node-browserify/blob/master/bin/cmd.js#L55

Install error: ftheader.h: No such file or directory

When I am trying to build matplotlib-1.3.1, I am getting the below freetype header errors. Probably it is not finding the ftheader.h. Any idea on how to solve this problem?
NOTE: I just installed Freetype-2.5.0.1 following the instructions as mentioned in
FreeType Install because manually building Matplotlib-1.3.1 from source was failing due to the required package 'freetype' which was not found initially.
In file included from src/ft2font.h:16,
from src/ft2font.cpp:3:
/usr/include/ft2build.h:56:38: error: freetype/config/ftheader.h: No such file or directory
In file included from src/ft2font.cpp:3:
src/ft2font.h:17:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:18:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:19:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:20:10: error: #include expects "FILENAME" or <FILENAME>
src/ft2font.h:21:10: error: #include expects "FILENAME" or <FILENAME>
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h:69,
from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/char_traits.h:41,
from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/string:42,
from ./CXX/Python2/Exception.hxx:46,
from ./CXX/Exception.hxx:40,
from ./CXX/Python2/Objects.hxx:44,
from ./CXX/Python2/Extensions.hxx:52,
from ./CXX/Extensions.hxx:40,
from src/ft2font.h:6,
from src/ft2font.cpp:3:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:91: error: expected template-name before ‘<’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:91: error: expected ‘{’ before ‘<’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:91: error: expected unqualified-id before ‘<’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:390: error: expected template-name before ‘<’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:390: error: expected ‘{’ before ‘<’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:390: error: expected unqualified-id before ‘<’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:474: error: expected template-name before ‘<’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:474: error: expected ‘{’ before ‘<’ token
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:474: error: expected unqualified-id before ‘<’ token
I tried running sudo yum install *-devel on a fresh vm which has neither numpy/scipy/matplotlib installed; but get the below error message which I received also on my previous VM image. Is it a problem specific to the VM I am using? Note: I am using Hortonworks Sandbox v1.3 over Oracle VirtualBox VM
Error: metis conflicts with cmake-2.6.4-5.el6.x86_64
Error: php-pecl-apcu conflicts with php-pecl-apc-3.1.9-2.el6.x86_64
Error: cpupowerutils-devel conflicts with cpufrequtils-devel-007-6.el6.x86_64
Error: Package: libgendersplusplus-1.20-1.el6.x86_64 (HDP-epel)
Requires: libgenders(x86-64) = 1.20-1.el6
Installing: libgenders-1.14-2.el6.rf.x86_64 (HDP-UTILS-1.1.0.15)
libgenders(x86-64) = 1.14-2.el6.rf
Error: zeromq3-devel conflicts with zeromq-devel-2.2.0-4.el6.x86_64
Error: Package: rubygem-passenger-devel-3.0.21-5.el6.x86_64 (HDP-epel)
Requires: rubygem(passenger) = 3.0.21-5.el6
Available: 1:rubygem-passenger-3.0.12-1.el6.x86_64 (HDP-UTILS-1.1.0.15)
rubygem(passenger) = 3.0.12
Error: Package: libgenders-devel-1.20-1.el6.x86_64 (HDP-epel)
Requires: libgenders(x86-64) = 1.20-1.el6
Installing: libgenders-1.14-2.el6.rf.x86_64 (HDP-UTILS-1.1.0.15)
libgenders(x86-64) = 1.14-2.el6.rf
Error: php-pecl-apcu-devel conflicts with php-pecl-apc-devel-3.1.9-2.el6.x86_64
Error: Package: libgenders-devel-1.20-1.el6.x86_64 (HDP-epel)
Requires: libgenders(x86-64) = 1.20-1.el6
Available: libgenders-1.14-2.el6.rf.x86_64 (HDP-UTILS-1.1.0.15)
libgenders(x86-64) = 1.14-2.el6.rf
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
Viewing the source tree under /usr/share/doc gives an estimate of the packages and their versions that come pre-installed in the sandbox. Note: You can clearly see freetype-2.3.11 in the list and lots of other lib packages which may be conflicting when *-dev is installed
acl-2.2.49 foomatic-db-4.0 libedit-2.11 mpfr-2.4.1 python-setuptools-0.6.10
acpid-1.0.10 fping-2.4b2 libffi-3.0.5 mx4j-3.0.1 python-urlgrabber-3.9.1
alsa-lib-1.0.22 freetype-2.3.11 libfontenc-1.0.5 mysql-5.1.69 qt3-3.3.8b
apache-tomcat-apis-0.1 fuse-2.8.3 libgcc-4.4.7 mysql-connector-java-5.1.17 qt4
apr-1.3.9 gamin-0.1.10 libgcrypt-1.4.5 mysql-libs-5.1.69 qt-4.6.2
apr-util-1.3.9 gawk-3.1.7 libgomp-4.4.7 mysql-server-5.1.69 readline-6.0
at-3.1.10 gcc-4.4.7 libgpg-error-1.7 nagios-3.2.3 redhat-logos-60.0.14
atk-1.28.0 gd-2.0.35 libgudev1-147 nagios-plugins-1.4.9 redhat-release
attr-2.4.44
For Mac OS 10.6.8
sudo ln -s /usr/X11/include/freetype2/freetype /usr/X11/include/.
Seems to do the trick... If you look at the /usr/X11/include/ft2build.h it seems as though it is really a problem with that header file and the way free type is installed, not a matplotlib problem.
Once installed (properly) the development package, the Freetype headers shall be in $(includedir)/freetype/freetype2 and $(includedir)/freetype2/freetype/config, with the only exception of ft2build.h which is in $(includedir).
It seems from the message you showed that indeed there is a ft2build.h file in /usr/include (a natural place for $(includedir)), yet the rest of the headers are not at the correct place.
I do not know exactly how to correct this since it is probably an issue with your particular distribution and the way you installed it, but I feel the most natural fix is to uninstall (properly) the freetype-dev[el] package, then re-install it, using of course the distribution-provided version which matches your installed .so, apparently 2.3.11.
Installing Freetype 2.5.0.1 will not help you until you successfully build the library, then install it in your system successfully; only then you will have the headers installed in $(includedir) and its sub-directories.
For RHEL use below command :
yum install freetype-devel -y
For Ubuntu use below command:
apt-get install libfreetype-dev -y