Related
I'm a junior front-end, and trying to learn Storybook for work.
I just created new react app with create-react-app and run npm start.
And it failed just in the screenshot below.
npm start failed error
But I just solved it after seeing an answer from stack-overflow just like in the screenshot below.
solved error of react-scripts#4.0.3
And I initiated storybook in my new react project with npx sb init just like the documentation says. It is succeed by creating .storybook folder and some example stories under src folder. Then, I run npm run storybook, and so many error appears in the console.
$ npm run storybook
> learn-storybook-5#0.1.0 storybook
> start-storybook -p 6006 -s public
info #storybook/react v6.4.9
info
(node:15528) DeprecationWarning: --static-dir CLI flag is deprecated, see:
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated---static-dir-cli-flag
(Use `node --trace-deprecation ...` to show where the warning was created)
info => Loading presets
info Found existing addon "#storybook/addon-docs", skipping.
info Found existing addon "#storybook/addon-actions", skipping.
info => Serving static files from ./public at /
info => Loading Webpack configuration from `node_modules\react-scripts`
info => Removing existing JavaScript and TypeScript rules.
info => Modifying Create React App rules.
info => Using default Webpack4 setup
10% building 1/1 modules 0 activeWARN Expected '#storybook/addon-docs' (or '#storybook/addon-essentials') to be listed before '#storybook/addon-controls' (or '#storybook/addon-essentials') in main Storybook config.
13% building 27/33 modules 6 active D:\311's learning\learn-storybook-5\node_modules\#pmmmwh\react-refresh-webpack-plugin\client\utils\safeThis.js
info => Using cached manager
webpack built preview d035dbd78ee6247b1305 in 9381ms
× 「wdm」: Hash: d035dbd78ee6247b1305
Version: webpack 4.44.2
Time: 9381ms
Built at: 12/10/2021 3:29:06 PM
Asset Size Chunks Chunk Names
0.iframe.bundle.js 226 KiB 0 [emitted]
0.iframe.bundle.js.map 215 KiB 0 [emitted] [dev]
1.iframe.bundle.js 206 KiB 1 [emitted]
1.iframe.bundle.js.map 145 KiB 1 [emitted] [dev]
2.iframe.bundle.js 9.15 KiB 2 [emitted]
2.iframe.bundle.js.map 6.47 KiB 2 [emitted] [dev]
3.iframe.bundle.js 92.4 KiB 3 [emitted]
3.iframe.bundle.js.map 84.3 KiB 3 [emitted] [dev]
4.iframe.bundle.js 372 KiB 4 [emitted] [big]
4.iframe.bundle.js.map 412 KiB 4 [emitted] [dev]
5.iframe.bundle.js 15.7 KiB 5 [emitted]
5.iframe.bundle.js.map 16.6 KiB 5 [emitted] [dev]
asset-manifest.json 1.67 KiB [emitted]
iframe.html 11.4 KiB [emitted]
main.iframe.bundle.js 111 KiB main [emitted] main
main.iframe.bundle.js.map 43 KiB main [emitted] [dev] main
runtime~main.iframe.bundle.js 37.9 KiB runtime~main [emitted] runtime~main
runtime~main.iframe.bundle.js.map 39.2 KiB runtime~main [emitted] [dev] runtime~main
static/media/code-brackets.2e1112d7.svg 1.42 KiB [emitted] [immutable]
static/media/colors.a4bd0486.svg 8.31 KiB [emitted] [immutable]
static/media/comments.a3859089.svg 1.49 KiB [emitted] [immutable]
static/media/direction.b770f9af.svg 1.25 KiB [emitted] [immutable]
static/media/flow.edad2ac1.svg 1.36 KiB [emitted] [immutable]
static/media/plugin.d494b228.svg 2.12 KiB [emitted] [immutable]
static/media/repo.6d496322.svg 1.6 KiB [emitted] [immutable]
static/media/stackalt.dba9fbb3.svg 2.49 KiB [emitted] [immutable]
vendors~main.iframe.bundle.js 4.64 MiB vendors~main [emitted] [big] vendors~main
vendors~main.iframe.bundle.js.map 4.16 MiB vendors~main [emitted] [dev] vendors~main
Entrypoint main [big] = runtime~main.iframe.bundle.js runtime~main.iframe.bundle.js.map vendors~main.iframe.bundle.js vendors~main.iframe.bundle.js.map main.iframe.bundle.js main.iframe.bundle.js.map
[0] multi ./node_modules/#pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js ./node_modules/#pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js ./node_modules/#storybook/core-client/dist/esm/globals/polyfills.js ./node_modules/#storybook/core-client/dist/esm/globals/globals.js (webpack)-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined ./storybook-init-framework-entry.js ./node_modules/#storybook/addon-docs/dist/esm/frameworks/common/config.js-generated-config-entry.js ./node_modules/#storybook/addon-docs/dist/esm/frameworks/react/config.js-generated-config-entry.js ./node_modules/#storybook/react/dist/esm/client/preview/config-generated-config-entry.js ./node_modules/#storybook/addon-links/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-backgrounds/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-backgrounds/dist/esm/preset/addParameter.js-generated-config-entry.js ./node_modules/#storybook/addon-measure/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-outline/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-actions/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-actions/dist/esm/preset/addArgs.js-generated-config-entry.js ./.storybook/preview.js-generated-config-entry.js ./generated-stories-entry.js 232 bytes {main} [built]
[./.storybook/preview.js-generated-config-entry.js] 3.91 KiB {main} [built] [failed] [1 error]
[./generated-stories-entry.js] 2.95 KiB {main} [built]
[./node_modules/#pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js] 2.38 KiB {vendors~main} [built]
[./node_modules/#pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js] 500 bytes {vendors~main} [built]
[./node_modules/#storybook/addon-actions/dist/esm/preset/addArgs.js-generated-config-entry.js] 699 bytes {vendors~main} [built] [failed] [1 error]
[./node_modules/#storybook/addon-actions/dist/esm/preset/addDecorator.js-generated-config-entry.js] 704 bytes {vendors~main} [built] [failed] [1 error]
[./node_modules/#storybook/addon-backgrounds/dist/esm/preset/addDecorator.js-generated-config-entry.js] 708 bytes {vendors~main} [built] [failed] [1 error]
[./node_modules/#storybook/addon-backgrounds/dist/esm/preset/addParameter.js-generated-config-entry.js] 708 bytes {vendors~main} [built] [failed] [1 error]
[./node_modules/#storybook/addon-docs/dist/esm/frameworks/common/config.js-generated-config-entry.js] 706 bytes {vendors~main} [built] [failed] [1 error][./node_modules/#storybook/addon-docs/dist/esm/frameworks/react/config.js-generated-config-entry.js] 705 bytes {vendors~main} [built] [failed] [1 error]
[./node_modules/#storybook/addon-links/dist/esm/preset/addDecorator.js-generated-config-entry.js] 702 bytes {vendors~main} [built] [failed] [1 error]
[./node_modules/#storybook/addon-measure/dist/esm/preset/addDecorator.js-generated-config-entry.js] 704 bytes {vendors~main} [built] [failed] [1 error]
[./node_modules/#storybook/addon-outline/dist/esm/preset/addDecorator.js-generated-config-entry.js] 704 bytes {vendors~main} [built] [failed] [1 error]
[./node_modules/#storybook/core-client/dist/esm/globals/globals.js] 105 bytes {vendors~main} [built]
+ 1184 hidden modules
ERROR in ./.storybook/preview.js-generated-config-entry.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: D:\311's learning\learn-storybook-5\.storybook\preview.js-generated-config-entry.js: Missing semicolon. (8:118)
6 |
7 | /* eslint-disable import/no-unresolved */
> 8 | import { addDecorator, addParameters, addLoader, addArgsEnhancer, addArgTypesEnhancer, setGlobalRender } from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/client-api';
| ^
9 | import { logger } from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/client-logger';
10 | import * as config from 'D:/311's learning/learn-storybook-5/.storybook/preview.js';
11 | Object.keys(config).forEach(function (key) {
at Object._raise (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:541:17)
at Object.raiseWithData (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:534:17)
at Object.raise (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:495:17)
at Object.semicolon (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:3550:10)
at Object.parseImport (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:14831:10)
at Object.parseStatementContent (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13454:27)
at Object.parseStatement (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13352:17)
at Object.parseStatement (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:5307:24)
at Object.parseBlockOrModuleBlockBody (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13941:25)
at Object.parseBlockBody (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13932:10)
at Object.parseProgram (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13272:10)
at Object.parseTopLevel (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13263:25)
at Object.parseTopLevel (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:6273:28)
at Object.parse (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:15037:10)
at parse (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:15089:38)
at parser (D:\311's learning\learn-storybook-5\node_modules\#babel\core\lib\parser\index.js:52:34)
# multi ./node_modules/#pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js ./node_modules/#pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js ./node_modules/#storybook/core-client/dist/esm/globals/polyfills.js ./node_modules/#storybook/core-client/dist/esm/globals/globals.js (webpack)-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined ./storybook-init-framework-entry.js ./node_modules/#storybook/addon-docs/dist/esm/frameworks/common/config.js-generated-config-entry.js ./node_modules/#storybook/addon-docs/dist/esm/frameworks/react/config.js-generated-config-entry.js ./node_modules/#storybook/react/dist/esm/client/preview/config-generated-config-entry.js ./node_modules/#storybook/addon-links/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-backgrounds/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-backgrounds/dist/esm/preset/addParameter.js-generated-config-entry.js ./node_modules/#storybook/addon-measure/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-outline/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-actions/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-actions/dist/esm/preset/addArgs.js-generated-config-entry.js ./.storybook/preview.js-generated-config-entry.js ./generated-stories-entry.js main[16]
ERROR in ./node_modules/#storybook/addon-actions/dist/esm/preset/addArgs.js-generated-config-entry.js 8:118
Module parse failed: Unexpected token (8:118)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| /* eslint-disable import/no-unresolved */
> import { addDecorator, addParameters, addLoader, addArgsEnhancer, addArgTypesEnhancer, setGlobalRender } from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/client-api';
| import { logger } from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/client-logger';
| import * as config from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/addon-actions/dist/esm/preset/addArgs.js';
# multi ./node_modules/#pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js ./node_modules/#pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js ./node_modules/#storybook/core-client/dist/esm/globals/polyfills.js ./node_modules/#storybook/core-client/dist/esm/globals/globals.js (webpack)-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined ./storybook-init-framework-entry.js ./node_modules/#storybook/addon-docs/dist/esm/frameworks/common/config.js-generated-config-entry.js ./node_modules/#storybook/addon-docs/dist/esm/frameworks/react/config.js-generated-config-entry.js ./node_modules/#storybook/react/dist/esm/client/preview/config-generated-config-entry.js ./node_modules/#storybook/addon-links/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-backgrounds/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-backgrounds/dist/esm/preset/addParameter.js-generated-config-entry.js ./node_modules/#storybook/addon-measure/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-outline/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-actions/dist/esm/preset/addDecorator.js-generated-config-entry.js ./node_modules/#storybook/addon-actions/dist/esm/preset/addArgs.js-generated-config-entry.js ./.storybook/preview.js-generated-config-entry.js ./generated-stories-entry.js main[15]
Child HtmlWebpackCompiler:
Asset Size Chunks Chunk Names
__child-HtmlWebpackPlugin_0 6.28 KiB HtmlWebpackPlugin_0 HtmlWebpackPlugin_0
Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0
[./node_modules/html-webpack-plugin/lib/loader.js!./node_modules/#storybook/core-common/dist/cjs/templates/index.ejs] 2.03 KiB {HtmlWebpackPlugin_0}
[built]
ModuleBuildError: Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: D:\311's learning\learn-storybook-5\.storybook\preview.js-generated-config-entry.js: Missing semicolon. (8:118)
6 |
7 | /* eslint-disable import/no-unresolved */
> 8 | import { addDecorator, addParameters, addLoader, addArgsEnhancer, addArgTypesEnhancer, setGlobalRender } from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/client-api';
| ^
9 | import { logger } from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/client-logger';
10 | import * as config from 'D:/311's learning/learn-storybook-5/.storybook/preview.js';
11 | Object.keys(config).forEach(function (key) {
at Object._raise (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:541:17)
at Object.raiseWithData (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:534:17)
at Object.raise (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:495:17)
at Object.semicolon (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:3550:10)
at Object.parseImport (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:14831:10)
at Object.parseStatementContent (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13454:27)
at Object.parseStatement (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13352:17)
at Object.parseStatement (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:5307:24)
at Object.parseBlockOrModuleBlockBody (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13941:25)
at Object.parseBlockBody (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13932:10)
at Object.parseProgram (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13272:10)
at Object.parseTopLevel (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:13263:25)
at Object.parseTopLevel (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:6273:28)
at Object.parse (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:15037:10)
at parse (D:\311's learning\learn-storybook-5\node_modules\#babel\parser\lib\index.js:15089:38)
at parser (D:\311's learning\learn-storybook-5\node_modules\#babel\core\lib\parser\index.js:52:34)
at D:\311's learning\learn-storybook-5\node_modules\webpack\lib\NormalModule.js:316:20
at D:\311's learning\learn-storybook-5\node_modules\loader-runner\lib\LoaderRunner.js:367:11
at D:\311's learning\learn-storybook-5\node_modules\loader-runner\lib\LoaderRunner.js:233:18
at context.callback (D:\311's learning\learn-storybook-5\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at D:\311's learning\learn-storybook-5\node_modules\babel-loader\lib\index.js:59:103
ModuleParseError: Module parse failed: Unexpected token (8:118)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| /* eslint-disable import/no-unresolved */
> import { addDecorator, addParameters, addLoader, addArgsEnhancer, addArgTypesEnhancer, setGlobalRender } from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/client-api';
| import { logger } from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/client-logger';
| import * as config from 'D:/311's learning/learn-storybook-5/node_modules/#storybook/addon-actions/dist/esm/preset/addArgs.js';
at handleParseError (D:\311's learning\learn-storybook-5\node_modules\webpack\lib\NormalModule.js:469:19)
at D:\311's learning\learn-storybook-5\node_modules\webpack\lib\NormalModule.js:503:5
at D:\311's learning\learn-storybook-5\node_modules\webpack\lib\NormalModule.js:358:12
at D:\311's learning\learn-storybook-5\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (D:\311's learning\learn-storybook-5\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at D:\311's learning\learn-storybook-5\node_modules\loader-runner\lib\LoaderRunner.js:205:4
at D:\311's learning\learn-storybook-5\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:85:15
at processTicksAndRejections (node:internal/process/task_queues:78:11)
WARN Broken build, fix the error above.
WARN You may need to refresh the browser.
I searched with possible keywords from the error on google and in-and-out stack-overflow links. I installed some addon in .storybook/main.js file. But nothing works. Below are my package.json file and two config file of storybook.
//package.json
{
"name": "learn-storybook-5",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.16.1",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "^4.0.3",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
],
"overrides": [
{
"files": [
"**/*.stories.*"
],
"rules": {
"import/no-anonymous-default-export": "off"
}
}
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#storybook/addon-actions": "^6.4.9",
"#storybook/addon-docs": "^6.4.9",
"#storybook/addon-essentials": "^6.4.9",
"#storybook/addon-links": "^6.4.9",
"#storybook/node-logger": "^6.4.9",
"#storybook/preset-create-react-app": "^3.2.0",
"#storybook/react": "^6.4.9"
}
}
//.storybook/main.js
module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.#(js|jsx|ts|tsx)'],
addons: [
'#storybook/addon-links',
'#storybook/addon-essentials',
'#storybook/preset-create-react-app',
'#storybook/addon-actions',
'#storybook/node-logger',
'#storybook/addon-docs',
],
framework: '#storybook/react',
}
//.storybook/preview.js
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
It has been two days that I can't even boost up stroybook :))
I hope someone could guide me.
The problem was my folder name 3ll's learning.
The single quote from my folder name conflicts with paths used in Stroybook's modules. That's it. Admin from Storybook discord server pointed out that to me.
I'm trying to deploy a nuxt app to Heroku but it keeps failing during build. Building and starting locally works perfectly. I've tried changing the paths for the components in default.vue (#/components, ~/components, ../components) and I still get 'Can't Resolve'. Also tried multiple versions of package.json based on other threads with similar issues, but nothing seems to work.
Photo of Folder Layout
Heroku Log:
remote: > nuxt build
remote:
remote: ℹ Production build
remote: ✔ Builder initialized
remote: ✔ Nuxt files generated
remote: ℹ Compiling Client
remote: ✔ Client: Compiled with some errors in 42.31s
remote:
remote: Hash: a7adf710e4a9a216bdca
remote: Version: webpack 4.41.3
remote: Time: 42318ms
remote: Built at: 12/17/2019 8:05:56 PM
remote: Asset Size Chunks Chunk Names
remote: 156549b9e5235b29714a.js 1010 bytes 2 [immutable] pages/about
remote: 1b7901f20ace318de4e2.js 5.05 KiB 3 [immutable] pages/index
remote: 2064a7c39737d73ecb9c.js 1.19 KiB 4 [immutable] pages/yelpcamp
remote: 493a442905cb865c2ca1.js 294 KiB 6 [immutable] vendors.app
remote: 519c9efdea0f9ea4ebdc.js 2.38 KiB 5 [immutable] runtime
remote: 55c6ba3ed3fe063a3d0e.js 167 KiB 1 [immutable] commons.app
remote: LICENSES 510 bytes
remote: aea3489e520195a48d62.js 37.2 KiB 7 [immutable] vendors.pages/index
remote: cbee6c8200953de76a3c.js 41.6 KiB 0 [immutable] app
remote: img/0288f57.jpg 233 KiB
remote: img/db28ad7.jpg 97.5 KiB
remote: Entrypoint app = 519c9efdea0f9ea4ebdc.js 55c6ba3ed3fe063a3d0e.js 493a442905cb865c2ca1.js cbee6c8200953de76a3c.js
remote:
remote: ERROR in ./layouts/default.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ref--2-0!./node_modules/vuetify-loader/lib/loader.js??ref--16-0!./node_modules/vue-loader/lib??vue-loader-options!./layouts/default.vue?vue&type=script&lang=js&)
remote: Module not found: Error: Can't resolve '../components/Navbar.vue' in '/tmp/build_28a528eb014098870414a8a1afe75600/layouts'
remote: # ./layouts/default.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ref--2-0!./node_modules/vuetify-loader/lib/loader.js??ref--16-0!./node_modules/vue-loader/lib??vue-loader-options!./layouts/default.vue?vue&type=script&lang=js&) 13:0-46 19:12-18
remote: # ./layouts/default.vue?vue&type=script&lang=js&
remote: # ./layouts/default.vue
remote: # ./.nuxt/App.js
remote: # ./.nuxt/index.js
remote: # ./.nuxt/client.js
remote: # multi ./.nuxt/client.js
remote:
remote: FATAL Nuxt build error
remote:
remote: at WebpackBundler.webpackCompile (node_modules/#nuxt/webpack/dist/webpack.js:5314:21)
remote: at runMicrotasks (<anonymous>)
remote: at processTicksAndRejections (internal/process/task_queues.js:97:5)
remote: at async WebpackBundler.build (node_modules/#nuxt/webpack/dist/webpack.js:5263:5)
remote: at async Builder.build (node_modules/#nuxt/builder/dist/builder.js:5597:5)
remote: at async Object.run (node_modules/#nuxt/cli/dist/cli-build.js:100:7)
remote: at async NuxtCommand.run (node_modules/#nuxt/cli/dist/cli-command.js:2575:7)
remote:
remote: tput: No value for $TERM and no -T specified
remote:
remote: ╭─────────────────────────────╮
remote: │ │
remote: │ ✖ Nuxt Fatal Error │
remote: │ │
remote: │ Error: Nuxt build error │
remote: │ │
remote: ╰─────────────────────────────╯
remote:
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! daltondayton#1.0.0 build: `nuxt build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the daltondayton#1.0.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.sAakk/_logs/2019-12-17T20_05_56_620Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! daltondayton#1.0.0 heroku-postbuild: `npm run build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the daltondayton#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.sAakk/_logs/2019-12-17T20_05_56_636Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to daltondayton.
remote:
To https://git.heroku.com/daltondayton.git
! [remote rejected] master -> master (pre-receive hook declined)
Package.json
{
"name": "daltondayton",
"version": "1.0.0",
"description": "daltondayton.com",
"engines": {
"node": "13.3.0"
},
"author": "Dalton Dayton",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"heroku-postbuild": "npm run build",
"generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
},
"dependencies": {
"#nuxtjs/axios": "^5.3.6",
"nuxt": "^2.10.2",
"vue": "^2.6.11"
},
"devDependencies": {
"#nuxtjs/vuetify": "^1.0.0",
"#nuxtjs/eslint-config": "^1.0.1",
"#nuxtjs/eslint-module": "^1.0.0",
"babel-eslint": "^10.0.1",
"eslint": "^6.1.0",
"eslint-plugin-nuxt": ">=0.4.2",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1",
"prettier": "^1.16.4"
}
}
Procfile:
web: npm run build && npm start -- --port $PORT
Did you happen to change the components' names in a case-sensitive only way?
Example: from fonts.vue to Fonts.vue.
I've run into a similar issue when deploying my nuxt project on Heroku. It seems that it has to do with mac OS being a case insensitive environment.
I was able to solve it by following these steps:
git mv fonts.vue fonts2.vue
git mv fonts2.vue Fonts.vue
git commit -m "changed case of file"
Notice that I had to change to fonts2.vue initially so that the case-sensitive renaming takes place effectively.
Here's the SO answer explaining the solution to this problem.
I'm trying to build msal so I can use it with nodejs. Specifically, I would like to verify e-mails are received by test users in end-to-end webdriverio tests.
I followed the npm msal guide here and got pretty far, but reached some errors during:
npm run build
.
npm run build
> msal#0.1.7 build C:\Users\User\TestAutomation\node_modules\msal
> npm run clean && npm run doc && npm run build:modules && webpack && grunt && npm test
> msal#0.1.7 clean C:\Users\User\TestAutomation\node_modules\msal
> shx rm -rf dist docs lib-commonjs lib-es6
> msal#0.1.7 doc C:\Users\User\TestAutomation\node_modules\msal
> typedoc --out ./docs ./src/**/* --gitRevision dev
Using TypeScript 2.2.2 from C:\Users\User\TestAutomation\node_modules\msal\node_modules\typedoc\node_modules\typescript\lib
Rendering [========================================] 100%
Documentation generated at C:\Users\User\TestAutomation\node_modules\msal\docs
> msal#0.1.7 build:modules C:\Users\User\TestAutomation\node_modules\msal
> tsc && tsc -m es6 --outDir lib-es6
Hash: 898d9837b77694c4a729
Version: webpack 3.12.0
Time: 244ms
Asset Size Chunks Chunk Names
msal.js 8.59 kB 0, 1 [emitted] msal
msal.min.js 3.26 kB 1, 0 [emitted] msal.min
msal.js.map 3.67 kB 0, 1 [emitted] msal
msal.min.js.map 14.4 kB 1, 0 [emitted] msal.min
[0] ./src/UserAgentApplication.ts 271 bytes {0} {1} [built] [failed] [1 error]
[1] ./src/Logger.ts 290 bytes {0} {1} [built] [failed] [1 error]
[2] multi ./src/index.ts 28 bytes {0} {1} [built]
[3] ./src/index.ts 354 bytes {0} {1} [built]
[4] ./src/User.ts 248 bytes {0} {1} [built] [failed] [1 error]
[5] ./src/Constants.ts 357 bytes {0} {1} [built] [failed] [1 error]
[6] ./src/RequestInfo.ts 247 bytes {0} {1} [built] [failed] [1 error]
[7] ./src/Authority.ts 209 bytes {0} {1} [built] [failed] [1 error]
ERROR in ./src/Logger.ts
Module parse failed: Unexpected token (26:7)
You may need an appropriate loader to handle this file type.
| import { Utils } from "./Utils";
|
| export interface ILoggerCallback {
| (level: LogLevel, message: string, containsPii: boolean): void;
| }
# ./src/index.ts 2:0-34 3:0-36
# multi ./src/index.ts
ERROR in ./src/Constants.ts
Module parse failed: Unexpected token (28:31)
You may need an appropriate loader to handle this file type.
| */
| export class Constants {
| static get errorDescription(): string { return "error_description"; }
| static get error(): string { return "error"; }
| static get scope(): string { return "scope"; }
# ./src/index.ts 5:0-40
# multi ./src/index.ts
ERROR in ./src/RequestInfo.ts
Module parse failed: Unexpected token (28:7)
You may need an appropriate loader to handle this file type.
| */
| export class TokenResponse {
| valid: boolean;
| parameters: Object;
| stateMatch: boolean;
# ./src/index.ts 6:0-45
# multi ./src/index.ts
ERROR in ./src/User.ts
Module parse failed: Unexpected token (30:17)
You may need an appropriate loader to handle this file type.
| export class User {
|
| displayableId: string;
| name: string;
| identityProvider: string;
# ./src/index.ts 4:0-30
# multi ./src/index.ts
ERROR in ./src/Authority.ts
Module parse failed: Unexpected token (34:7)
You may need an appropriate loader to handle this file type.
| * #hidden
| */
| export enum AuthorityType {
| Aad,
| Adfs,
# ./src/index.ts 7:0-38
# multi ./src/index.ts
ERROR in ./src/UserAgentApplication.ts
Module parse failed: Unexpected token (39:8)
You may need an appropriate loader to handle this file type.
| import { AuthorityFactory } from "./AuthorityFactory";
|
| declare global {
| interface Window {
| msal: Object;
# ./src/index.ts 1:0-62 8:0-51
# multi ./src/index.ts
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! msal#0.1.7 build: `npm run clean && npm run doc && npm run build:modules && webpack && grunt && npm test`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the msal#0.1.7 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:
I think this is a babel error:
You may need an appropriate loader to handle this file type
But I am not sure how to resolve it. I tried installing babel also, not sure if I need it somewhere.
I'm a bit new to these tools, so I'm sure this is a simple mistake. I spent a bit of time on it, so I wanted to reach out for help. If I resolve it, I'll update this question.
Much appreciated to the MS team for providing msal.
Update: Including webpack.config.js
The webpack.config.js auto-generated by npm install msal:
var path = require("path");
var webpack = require("webpack");
var PATHS = {
entryPoint: path.resolve(__dirname, 'src/index.ts'),
bundles: path.resolve(__dirname, 'dist'),
}
var config = {
entry: {
'msal': [PATHS.entryPoint],
'msal.min': [PATHS.entryPoint]
},
output: {
path: PATHS.bundles,
filename: '[name].js',
libraryTarget: 'umd',
library: 'Msal',
umdNamedDefine: true
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
devtool: 'source-map',
plugins: [
new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap: true,
include: /\.min\.js$/,
})
],
module: {
loaders: [{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/,
query: {
declaration: false,
}
}]
}
}
module.exports = config;
You may need an appropriate loader to handle this file type refers to the fact that you're missing a loader for a specific file type.
Looking at the error message, it seems to be failing on the .ts files. Any chance you forgot to add a Typescript file loader (ts-loader) for the typescript files which it seems to be failing on?
EDIT
1) You're using loaders: for the loaders. I don't know if this affects it in any sense, since it seems the configuration still can be used in Webpack 3.
(I cannot use loaders: inside my Webpack 4 config, as it's marked as invalid by webpack upon compilation).
So I wanted to figure out if it made a big difference, and whilst stumbling around I did find the typescript sample for MSAL here. It looks like they're using rules as well in their configuration.
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader'
}
]
},
Honestly, I don't know if this makes a difference or not.
I edited the question.
If someone can help me to understand why my test doesn't work, it would be very appreciated.
It seems to me that Selenium server starts and Chromedriver starts (please take a look at 'selenium-debug.log' section), but tests scripts are not executed.
My codes work on my Mac, but I don't know why they don't on a Linux server.
My codes are here: https://github.com/watarumohawk/nightwatchjs-e2e
On the server, node is v7.2.0, and npm is v4.0.5. So I installed these versions on my Mac, but I still can't reproduce the issue on my Mac.
On my Mac, 'npm run test:amazon' and 'node_modules/nightwatch/bin/nightwatch' work.
On the Linux server, I tried this:
node_modules/nightwatch/bin/nightwatch
$ node_modules/nightwatch/bin/nightwatch
Starting selenium server in parallel mode... started - PID: 29825
Started child process for: amazon/amazon-top
>> amazon/amazon-top finished.
npm run test:amazon
$ npm run test:amazon
> Nightwatch-e2e#1.1.0 test:amazon /home/foo/work/hoge/nightwatchjs-e2e
> nightwatch --group amazon
Starting selenium server in parallel mode... started - PID: 30066
Started child process for: amazon/amazon-top
>> amazon/amazon-top finished.
npm ERR! Linux 3.10.0-327.4.5.el7.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test:amazon"
npm ERR! node v7.2.0
npm ERR! npm v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! Nightwatch-e2e#1.1.0 test:amazon: `nightwatch --group amazon`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Nightwatch-e2e#1.1.0 test:amazon script 'nightwatch --group amazon'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Nightwatch-e2e package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nightwatch --group amazon
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs Nightwatch-e2e
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls Nightwatch-e2e
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/foo/work/hoge/nightwatchjs-e2e/npm-debug.log
Settings:
package.json
{
......
"scripts": {
"test": "nightwatch",
"test:amazon": "nightwatch --group amazon"
},
"dependencies": {
"chai-nightwatch": "^0.1.1",
"chromedriver": "^2.32.3",
"nightwatch": "^0.9.16",
"selenium-server-standalone-jar": "3.6.0"
},
"devDependencies": {}
}
nightwatch.json
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"test_workers" : {"enabled" : true, "workers" : "auto"},
"selenium" : {
"start_process" : true,
"server_path" : "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.6.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "node_modules/chromedriver/lib/chromedriver/chromedriver",
"webdriver.ie.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"firefox_profile": false,
"chrome_driver" : "",
"screenshots" : {
"enabled" : true,
"path" : "screenshots",
"on_failure": true,
"on_error": false
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": ["--headless","--window-size=1920,1080"]
},
"use_xpath": false
}
}
}
}
Logs:
selenium-debug.log
15:31:22.180 INFO - Selenium build info: version: '3.6.0', revision: '6fbf3ec767'
15:31:22.180 INFO - Launching a standalone Selenium Server
2017-10-19 15:31:22.193:INFO::main: Logging initialized #159ms to org.seleniumhq.jetty9.util.log.StdErrLog
15:31:22.228 INFO - Driver class not found: com.opera.core.systems.OperaDriver
15:31:22.247 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
15:31:22.247 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
15:31:22.247 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX
15:31:22.264 INFO - Using the passthrough mode handler
2017-10-19 15:31:22.281:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-10-19 15:31:22.297:WARN:osjs.SecurityHandler:main: ServletContext#o.s.j.s.ServletContextHandler#eec5a4a{/,null,STARTING} has uncovered http methods for path: /
2017-10-19 15:31:22.300:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#eec5a4a{/,null,AVAILABLE}
2017-10-19 15:31:22.310:INFO:osjs.AbstractConnector:main: Started ServerConnector#9660f4e{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-10-19 15:31:22.311:INFO:osjs.Server:main: Started #278ms
15:31:22.311 INFO - Selenium Server is up and running
2017-10-19 15:31:22.528:INFO:osjshC.ROOT:qtp1910163204-11: org.openqa.selenium.remote.server.WebDriverServlet-28d25987: Initialising WebDriverServlet
15:31:22.552 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService
15:31:22.553 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#41c87be0
15:31:22.555 INFO - /session: Executing POST on /session (handler: BeginSession)
15:31:22.587 INFO - Capabilities are: Capabilities {acceptSslCerts=true, name=Amazon / Amazon Top, browserName=chrome, javascriptEnabled=true, use_xpath=false, chromeOptions={args=[--headless, --window-size=1920,1080]}, platformName=ANY, platform=ANY, }
15:31:22.587 INFO - Capabilities {acceptSslCerts=true, name=Amazon / Amazon Top, browserName=chrome, javascriptEnabled=true, use_xpath=false, chromeOptions={args=[--headless, --window-size=1920,1080]}, platformName=ANY, platform=ANY, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
15:31:22.588 INFO - Capabilities {acceptSslCerts=true, name=Amazon / Amazon Top, browserName=chrome, javascriptEnabled=true, use_xpath=false, chromeOptions={args=[--headless, --window-size=1920,1080]}, platformName=ANY, platform=ANY, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
15:31:22.588 INFO - Capabilities {acceptSslCerts=true, name=Amazon / Amazon Top, browserName=chrome, javascriptEnabled=true, use_xpath=false, chromeOptions={args=[--headless, --window-size=1920,1080]}, platformName=ANY, platform=ANY, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4) on port 27120
Only local connections are allowed.
npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'test:amazon' ]
2 info using npm#4.0.5
3 info using node#v7.2.0
4 verbose run-script [ 'pretest:amazon', 'test:amazon', 'posttest:amazon' ]
5 info lifecycle Nightwatch-e2e#1.1.0~pretest:amazon: Nightwatch-e2e#1.1.0
6 silly lifecycle Nightwatch-e2e#1.1.0~pretest:amazon: no script for pretest:amazon, continuing
7 info lifecycle Nightwatch-e2e#1.1.0~test:amazon: Nightwatch-e2e#1.1.0
8 verbose lifecycle Nightwatch-e2e#1.1.0~test:amazon: unsafe-perm in lifecycle true
9 verbose lifecycle Nightwatch-e2e#1.1.0~test:amazon: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/foo/work/hoge/nightwatchjs-e2e/node_modules/.bin:/home/foo/.pyenv/shims:/home/foo/.pyenv/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/foo/.local/bin:/home/foo/bin
10 verbose lifecycle Nightwatch-e2e#1.1.0~test:amazon: CWD: /home/foo/work/hoge/nightwatchjs-e2e
11 silly lifecycle Nightwatch-e2e#1.1.0~test:amazon: Args: [ '-c', 'nightwatch --group amazon' ]
12 silly lifecycle Nightwatch-e2e#1.1.0~test:amazon: Returned: code: 1 signal: null
13 info lifecycle Nightwatch-e2e#1.1.0~test:amazon: Failed to exec test:amazon script
14 verbose stack Error: Nightwatch-e2e#1.1.0 test:amazon: `nightwatch --group amazon`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:885:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid Nightwatch-e2e#1.1.0
16 verbose cwd /home/foo/work/hoge/nightwatchjs-e2e
17 error Linux 3.10.0-327.4.5.el7.x86_64
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test:amazon"
19 error node v7.2.0
20 error npm v4.0.5
21 error code ELIFECYCLE
22 error Nightwatch-e2e#1.1.0 test:amazon: `nightwatch --group amazon`
22 error Exit status 1
23 error Failed at the Nightwatch-e2e#1.1.0 test:amazon script 'nightwatch --group amazon'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the Nightwatch-e2e package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error nightwatch --group amazon
23 error You can get information on how to open an issue for this project with:
23 error npm bugs Nightwatch-e2e
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls Nightwatch-e2e
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
I am experimenting with webpack and wanted to use, among others, the bootstrap4 and font-awesome. All modules are recognized except these two.
The package.json created after npm install <module>:
{
"name": "blog",
"version": "1.0.0",
"description": "my site",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.0.0",
"bootstrap4": "0.0.1-security",
"css-loader": "^0.28.4",
"font-awesome": "^4.7.0",
"less": "^2.7.2",
"less-loader": "^4.0.4",
"lodash": "^4.17.4",
"moment": "^2.18.1",
"style-loader": "^0.18.2",
"vue": "^2.3.4"
}
}
The webpack.config.js file I use:
const path = require('path');
module.exports = {
entry: path.join(__dirname, 'entry.js'),
output: {
path: path.join(__dirname, 'src'),
filename: 'build.js'
},
module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.less$/,
use: ['style-loader', 'css-loader', 'less-loader']
}
]
}
}
Running webpack generates errors for bootstrap4 and font-awesome:
D:\Dropbox\dev\jekyll\blog\webpack>webpack
Hash: 2501a45f8eacb5b3fdac
Version: webpack 2.7.0
Time: 3028ms
Asset Size Chunks Chunk Names
build.js 1.24 MB 0 [emitted] [big] main
[0] ./~/moment/moment.js 129 kB {0} [built]
[14] ./~/moment/locale/bo.js 3.47 kB {0} [optional] [built]
[117] ./~/style-loader/lib/addStyles.js 8.7 kB {0} [built]
[118] (webpack)/buildin/global.js 509 bytes {0} [built]
[119] (webpack)/buildin/module.js 517 bytes {0} [built]
[120] ./js/explorer.js 1.35 kB {0} [built]
[121] ./~/lodash/lodash.js 540 kB {0} [built]
[122] ./less/navbar.less 1.13 kB {0} [built]
[123] ./less/style.less 1.12 kB {0} [built]
[124] ./~/vue/dist/vue.runtime.esm.js 195 kB {0} [built]
[125] ./entry.js 572 bytes {0} [built]
[126] ./~/css-loader!./~/less-loader/dist/cjs.js!./less/navbar.less 2.8 kB {0} [built]
[127] ./~/css-loader!./~/less-loader/dist/cjs.js!./less/style.less 7.67 kB {0} [built]
[128] ./~/moment/locale ^\.\/.*$ 2.79 kB {0} [optional] [built]
[129] ./~/process/browser.js 5.42 kB {0} [built]
+ 116 hidden modules
ERROR in ./entry.js
Module not found: Error: Can't resolve 'font-awesome' in 'D:\Dropbox\dev\jekyll\blog\webpack'
# ./entry.js 16:0-39
ERROR in ./entry.js
Module not found: Error: Can't resolve 'bootstrap4' in 'D:\Dropbox\dev\jekyll\blog\webpack'
# ./entry.js 15:0-36
The referenced entry.js:
import Vue from 'vue'
import bootstrap4 from 'bootstrap4'
import fontawesome from 'font-awesome'
import _ from 'lodash'
import moment from 'moment'
require('./less/style.less')
require('./less/navbar.less')
//require('./js/posts.js')
require('./js/explorer.js')
console.log('hello')
Why are these two modules a problem?
The complete error log from webpack, for completeness:
D:\Dropbox\dev\jekyll\blog\webpack>webpack --display-error-details
Hash: 2501a45f8eacb5b3fdac
Version: webpack 2.7.0
Time: 2952ms
Asset Size Chunks Chunk Names
build.js 1.24 MB 0 [emitted] [big] main
[0] ./~/moment/moment.js 129 kB {0} [built]
[14] ./~/moment/locale/bo.js 3.47 kB {0} [optional] [built]
[117] ./~/style-loader/lib/addStyles.js 8.7 kB {0} [built]
[118] (webpack)/buildin/global.js 509 bytes {0} [built]
[119] (webpack)/buildin/module.js 517 bytes {0} [built]
[120] ./js/explorer.js 1.35 kB {0} [built]
[121] ./~/lodash/lodash.js 540 kB {0} [built]
[122] ./less/navbar.less 1.13 kB {0} [built]
[123] ./less/style.less 1.12 kB {0} [built]
[124] ./~/vue/dist/vue.runtime.esm.js 195 kB {0} [built]
[125] ./entry.js 572 bytes {0} [built]
[126] ./~/css-loader!./~/less-loader/dist/cjs.js!./less/navbar.less 2.8 kB {0} [built]
[127] ./~/css-loader!./~/less-loader/dist/cjs.js!./less/style.less 7.67 kB {0} [built]
[128] ./~/moment/locale ^\.\/.*$ 2.79 kB {0} [optional] [built]
[129] ./~/process/browser.js 5.42 kB {0} [built]
+ 116 hidden modules
ERROR in ./entry.js
Module not found: Error: Can't resolve 'font-awesome' in 'D:\Dropbox\dev\jekyll\blog\webpack'
resolve 'font-awesome' in 'D:\Dropbox\dev\jekyll\blog\webpack'
Parsed request is a module
using description file: D:\Dropbox\dev\jekyll\blog\webpack\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
after using description file: D:\Dropbox\dev\jekyll\blog\webpack\package.json (relative path: .)
resolve as module
D:\Dropbox\dev\jekyll\blog\node_modules doesn't exist or is not a directory
D:\Dropbox\dev\jekyll\node_modules doesn't exist or is not a directory
D:\Dropbox\dev\node_modules doesn't exist or is not a directory
D:\Dropbox\node_modules doesn't exist or is not a directory
D:\node_modules doesn't exist or is not a directory
looking for modules in D:\Dropbox\dev\jekyll\blog\webpack\node_modules
using description file: D:\Dropbox\dev\jekyll\blog\webpack\package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: D:\Dropbox\dev\jekyll\blog\webpack\package.json (relative path: ./node_modules)
using description file: D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome\package.json (relative path: .)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome is not a file
.js
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome.json doesn't exist
as directory
existing directory
using path: D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome\index
using description file: D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome\package.json (relative path: ./index)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome\index doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome\index.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome\index.json doesn't exist
[D:\Dropbox\dev\jekyll\blog\node_modules]
[D:\Dropbox\dev\jekyll\node_modules]
[D:\Dropbox\dev\node_modules]
[D:\Dropbox\node_modules]
[D:\node_modules]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome.js]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome.json]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome\index]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome\index.js]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\font-awesome\index.json]
# ./entry.js 16:0-39
ERROR in ./entry.js
Module not found: Error: Can't resolve 'bootstrap4' in 'D:\Dropbox\dev\jekyll\blog\webpack'
resolve 'bootstrap4' in 'D:\Dropbox\dev\jekyll\blog\webpack'
Parsed request is a module
using description file: D:\Dropbox\dev\jekyll\blog\webpack\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
after using description file: D:\Dropbox\dev\jekyll\blog\webpack\package.json (relative path: .)
resolve as module
D:\Dropbox\dev\jekyll\blog\node_modules doesn't exist or is not a directory
D:\Dropbox\dev\jekyll\node_modules doesn't exist or is not a directory
D:\Dropbox\dev\node_modules doesn't exist or is not a directory
D:\Dropbox\node_modules doesn't exist or is not a directory
D:\node_modules doesn't exist or is not a directory
looking for modules in D:\Dropbox\dev\jekyll\blog\webpack\node_modules
using description file: D:\Dropbox\dev\jekyll\blog\webpack\package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: D:\Dropbox\dev\jekyll\blog\webpack\package.json (relative path: ./node_modules)
using description file: D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\package.json (relative path: .)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4 is not a file
.js
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4.json doesn't exist
as directory
existing directory
use ./index.js from main in package.json
using description file: D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
after using description file: D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\package.json (relative path: .)
using description file: D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\package.json (relative path: ./index.js)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js.json doesn't exist
as directory
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js doesn't exist
using path: D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index
using description file: D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\package.json (relative path: ./index)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.json doesn't exist
[D:\Dropbox\dev\jekyll\blog\node_modules]
[D:\Dropbox\dev\jekyll\node_modules]
[D:\Dropbox\dev\node_modules]
[D:\Dropbox\node_modules]
[D:\node_modules]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4.js]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4.json]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js.js]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js.json]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.js]
[D:\Dropbox\dev\jekyll\blog\webpack\node_modules\bootstrap4\index.json]
# ./entry.js 15:0-36
font-awesome does not have any fields in package.json that are recognised by webpack and there is also no index.js in the package, therefore it can't be imported as usual. Presumably you want to use the CSS file, so you could import it like this.
import 'font-awesome/css/font-awesome.css';
bootstrap4 is not a real package. From the npm registry - bootstrap4:
Security holding package
This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.
You may adopt this package by contacting support#npmjs.com and requesting the name.
You need the actual boostrap package. The stable version is currently 3.3.7, but the v4 alpha is available on npm. You can install it with:
npm install --save bootstrap#next
You can indeed make font-awesome work nicely with webpack. Add the element "style" to resolve.mainFields:
module.exports = {
...
resolve: {
...
mainFields: ["browser", "module", "main", "style"]
...
}
...
}
The first three values come from the docs, and the last one comes from the font-awesome package.json field:
{
...
"style": "css/font-awesome.css",
...
}
Now webpack knows where font-awesome keeps its CSS! Do keep in mind that webpack will set a default value for resolve.mainFields based on the webpack config field target; This change negates this behavior, so you'll have to read the docs for the correct resolve.mainField values.