Cannot find module error for interfaces in Angular Universal build - angular-universal

My Angular 7 portfolio-app with ngUniversal is setup as per the official cli documentation. I have interfaces set up for incoming data and some common functions.
"scripts": {
"ng": "ng",
"start": "npm run serve:ssr",
"build": "npm run build:ssr",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"compile:server": "webpack --config webpack.server.config.js --progress --colors",
"serve:ssr": "node dist/server",
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
"build:client-and-server-bundles": "ng build --prod && ng run my-portfolio:server:production"
}
Interface description and folder structure:
Component using the interface:
Problem
The universal build fails while running ng run my-portfolio:server:production following with error as shown in the screenshot.
Cause: Interfaces and common functions which are not registered in any modules. They're simply imported in the components.
Full error:
PS C:\Acclaris\Practice\AngularPractice\my-portfolio> npm run build
my-portfolio#0.0.0 build
C:\Acclaris\Practice\AngularPractice\my-portfolio npm run build:ssr
my-portfolio#0.0.0 build:ssr
C:\Acclaris\Practice\AngularPractice\my-portfolio npm run
build:client-and-server-bundles && npm run compile:server
my-portfolio#0.0.0 build:client-and-server-bundles
C:\Acclaris\Practice\AngularPractice\my-portfolio ng build --prod &&
ng run my-portfolio:server:production
Date: 2019-05-10T10:14:15.321Z Hash: 49ca0a31b14b3f2ef33f Time:
28138ms chunk {0} runtime.274b2b523ee7c9b8154c.js (runtime) 2.19 kB
[entry] [rendered] chunk {1} es2015-polyfills.c5dd28b362270c767b34.js
(es2015-polyfills) 56.4 kB [initial] [rendered] chunk {2}
main.c6958b8ee410ac47c079.js (main) 708 kB [initial] [rendered] chunk
{3} polyfills.8bbb231b43165d65d357.js (polyfills) 41 kB [initial]
[rendered] chunk {4} styles.3e7ad83f8f97d37ca687.css (styles) 61.6 kB
[initial] [rendered] chunk {5} 5.da6e7079542863691897.js () 1.92 kB
[rendered] chunk {6} 6.89f434210c8e48ff257a.js () 718 bytes
[rendered] chunk {7} 7.04704f420e92f76cb831.js () 5.2 kB [rendered]
Date: 2019-05-10T10:14:28.776Z Hash: a1b5d85a17ec5299c6a4 Time: 8780ms
chunk {main} main.js, main.js.map (main) 4.17 kB [entry] [rendered]
ERROR in
src/app/shared/components/portfolio-builder/portfolio-builder.component.ts(2,27):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/core/portfolio/portfolio.component.ts(2,27): error TS2307:
Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/portfolio-builder/body/body.component.ts(2,22):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/sections/education/education.component.ts(2,27):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/sections/education/education.component.ts(3,33):
error TS2307: Cannot find module
'src/app/shared/functions/function-library'.
src/app/shared/components/utilities/edulet/edulet.component.ts(2,27):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/portfolio-builder/footer/footer.component.ts(2,26):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/portfolio-builder/header/header.component.ts(2,24):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/sections/profile/profile.component.ts(2,25):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/portfolio-builder/sidebar/sidebar.component.ts(2,32):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/sections/sidebar-section/sidebar-section.component.ts(2,32):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/sections/work/work.component.ts(2,22): error
TS2307: Cannot find module 'src/app/shared/interfaces'.
src/app/shared/components/sections/work/work.component.ts(3,33): error
TS2307: Cannot find module
'src/app/shared/functions/function-library'.
src/app/shared/components/utilities/worklet/worklet.component.ts(2,22):
error TS2307: Cannot find module 'src/app/shared/interfaces'.
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-portfolio#0.0.0
build:client-and-server-bundles: ng build --prod && ng run
my-portfolio:server:production npm ERR! Exit status 1 npm ERR! npm
ERR! Failed at the my-portfolio#0.0.0 build:client-and-server-bundles
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\debmallya.bhattachar\AppData\Roaming\npm-cache_logs\2019-05-10T10_14_28_865Z-debug.log
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-portfolio#0.0.0
build:ssr: npm run build:client-and-server-bundles && npm run
compile:server npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the
my-portfolio#0.0.0 build:ssr 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\debmallya.bhattachar\AppData\Roaming\npm-cache_logs\2019-05-10T10_14_28_983Z-debug.log
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-portfolio#0.0.0
build: npm run build:ssr npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the my-portfolio#0.0.0 build 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\debmallya.bhattachar\AppData\Roaming\npm-cache_logs\2019-05-10T10_14_29_044Z-debug.log

Change import path of Portfolio interface from the one starting with 'src/app/*' to the direct path.
For example, for your PortfolioBuilderComponent import should look like this:
import { Portfolio } from '../../interfaces/portfolio'

Related

npm run dev command throwing error laravel 9.21.6

When i am opening a page it shows error
Vite manifest not found at: C:\xampp\htdocs\laravel_project\lara_project\public/build/manifest.json
and my command prompt showing error
# dev C:\xampp\htdocs\laravel_project\lara_project
vite
internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. Received protocol 'node:'
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:756:11)
at Loader.resolve (internal/modules/esm/loader.js:85:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:229:28)
at ModuleWrap. (internal/modules/esm/module_job.js:51:40)
at link (internal/modules/esm/module_job.js:50:36) {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: vite
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev 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\Sudha\AppData\Roaming\npm-cache_logs\2022-07-24T09_53_42_124Z-debug.log

Laravel project stops building with Datatables.net build issue

I am working on a Laravel project hosted on Heroku. A few days ago, it stopped building and produced the following error message.
ℹ Compiling Mix
[webpack-cli] [Error: ENOENT: no such file or directory, open '/tmp/src/js/vendors/plugins/datatables.init.js'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/tmp/src/js/vendors/plugins/datatables.init.js'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! undefined postinstall: npm run production
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the undefined postinstall 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! /tmp/npmcache.xfkpj/_logs/2021-11-10T16_57_33_522Z-debug.log
Any ideas?

Parcel build command throws an error when trying to compile

When i run "npm run dev" it works like a charm, but when i start "npm run dev", this is what happens. I have parcel,sass and yeoman.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! parcel-sass-boilerplate#1.0.0 build: `parcel build src/index.html`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the parcel-sass-boilerplate#1.0.0 build 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\nikok\AppData\Roaming\npm-cache\_logs\2021-09-28T07_20_11_855Z-debug.log
Add --no-minify into script like this:
"build": "parcel build src/index.html --no-minify"

Laravel - npm run dev - Failed to find '~#fortawesome/fontawesome-pro/css/all.min.css'

I have created a project in Laravel 8, and when I run npm run dev it throws the following error:
ERROR in ./resources/sass/app.scss (./node_modules/css-loader??ref--5-2!./node_modules/postcss-loader/src??postcss0!./node_modules/resolve-url-loader??ref--5-4!./node_modules/sass-loader/dist/cjs.js??ref--5-5!./resources/sass/app.scss)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Failed to find '~#fortawesome/fontawesome-pro/css/all.min.css'
in [
/Users/me/Laravel/<projectName>/resources/sass
]
at resolveModule.catch.catch (/Users/me/Laravel/<projectName>/node_modules/postcss-import/lib/resolve-id.js:35:13)
at <anonymous>
# ./resources/sass/app.scss 2:14-253
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # development 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! /Users/me/.npm/_logs/2020-12-30T08_24_47_410Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # dev: `npm run development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # dev 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! /Users/me/.npm/_logs/2020-12-30T08_24_47_441Z-debug.log
My resources/sass/app.scss looks like this:
#import '~#fortawesome/fontawesome-pro/css/all.min.css';
I've tried with #import 'node_modules/#fortawesome/fontawesome-pro/css/all.min.css' as well, but that doesn't work either.
I can see all.min.css in the tree when I follow the path node_modules/#fortawesome/fontawesome-pro/css/all.min.css so I know for a fact that it's there.
Any help would be appreciated
You need to remove the ~ before the import line:
#import '#fortawesome/fontawesome-pro/css/all.min.css';

Failed to execute 'npm run dist' at command (node build/build-plugins.js) loader.js:775 MODULE_NOT_FOUND

I'm currently following a tooling setup from Bootstrap but I'm really having a hard time trying to understand this.
This is the source of the step-by-step process (https://getbootstrap.com/docs/4.3/getting-started/build-tools/)
Currently, I'm able to run npm scripts (e.g. npm run dist - according to the package.json file from Bootstrap)
During the command ('npm run dist') there's a command being executed as:
node build/build-plugins.js (My Bootstrap root folder doesn't have any build folder!)
Here's the log (using Git Bash - Windows)
> bootstrap#4.3.1 js-compile-plugins C:\Workspace\risco-operacional\RiscoOperacional\packages\bootstrap.4.3.1
> node build/build-plugins.js
> bootstrap#4.3.1 css-compile-docs C:\Workspace\risco-operacional\RiscoOperacional\packages\bootstrap.4.3.1
> cross-env-shell node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 site/docs/$npm_package_version_short/assets/scss/docs.scss site/docs/$npm_package_version_short/assets/css/docs.min.css
> bootstrap#4.3.1 js-compile-plugins-coverage C:\Workspace\risco-operacional\RiscoOperacional\packages\bootstrap.4.3.1
> cross-env NODE_ENV=test node build/build-plugins.js
internal/modules/cjs/loader.js:775
throw err;
^
Error: Cannot find module 'C:\Workspace\risco-operacional\RiscoOperacional\packages\bootstrap.4.3.1\build\build-plugins.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bootstrap#4.3.1 js-compile-plugins-coverage: `cross-env NODE_ENV=test node build/build-plugins.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bootstrap#4.3.1 js-compile-plugins-coverage 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\srebelo001\AppData\Roaming\npm-cache\_logs\2019-09-01T13_54_39_217Z-debug.log
fs.js:127
throw err;
^
Error: ENOENT: no such file or directory, lstat 'C:\Workspace\risco-operacional\RiscoOperacional\packages\bootstrap.4.3.1\build'
at Object.realpathSync (fs.js:1512:7)
at runRollup (C:\Users\srebelo001\AppData\Roaming\npm\node_modules\rollup\dist\bin\rollup:1312:29)
at Object.<anonymous> (C:\Users\srebelo001\AppData\Roaming\npm\node_modules\rollup\dist\bin\rollup:1363:5)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11 {
errno: -4058,
syscall: 'lstat',
code: 'ENOENT',
path: 'C:\\Workspace\\risco-operacional\\RiscoOperacional\\packages\\bootstrap.4.3.1\\build'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bootstrap#4.3.1 js-compile-bundle: `rollup --environment BUNDLE:true --config build/rollup.config.js --sourcemap`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bootstrap#4.3.1 js-compile-bundle 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\srebelo001\AppData\Roaming\npm-cache\_logs\2019-09-01T13_54_39_354Z-debug.log
ERROR: "js-compile-plugins-coverage" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bootstrap#4.3.1 js-compile: `npm-run-all --parallel js-compile-* --sequential js-copy`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bootstrap#4.3.1 js-compile 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\srebelo001\AppData\Roaming\npm-cache\_logs\2019-09-01T13_54_39_938Z-debug.log
ERROR: "js-compile" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bootstrap#4.3.1 js: `npm-run-all js-compile js-minify js-copy`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bootstrap#4.3.1 js 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\srebelo001\AppData\Roaming\npm-cache\_logs\2019-09-01T13_54_39_973Z-debug.log
ERROR: "js" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bootstrap#4.3.1 dist: `npm-run-all --parallel css js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bootstrap#4.3.1 dist 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\srebelo001\AppData\Roaming\npm-cache\_logs\2019-09-01T13_54_40_318Z-debug.log
You propably ran npm install bootstrap command to download the source code of Bootstrap so you're missing build folder.
Try to download the source code with Composer. These steps worked for me:
composer require twbs/bootstrap:4.5.0
cd .\vendor\twbs\bootstrap\
npm install
npm run dist
(Evn.: Windows 10 + PowerShell, installed npm, node.js, Ruby+Devkit with Bundler and Jekyll)
Recommended instructions: https://getbootstrap.com/docs/4.5/getting-started/build-tools/

Resources