webpack-dev-middleware My ts module parsing error after use?









up vote
1
down vote

favorite












this is error message 1



enter image description here



I don't know why, my package goes to the folder where the current file is located instead of going to node_modules.



this is error message 2



enter image description here



This is my root Folder tree:



.
├── dist
├── gulpfile.js
├── interface
├── node_modules
├── package.json
├── README.md
├── scripts
├── spec
├── __test__
├── yarn.lock
└── yarn-offline


This is my cms2 Folder tree:



.
├── bin
├── config
├── createStore.ts
├── css
├── declarations.d.ts
├── env.ts
├── favicon.ico
├── index.html
├── node_modules
├── package.json
├── redux-form-immutable.d.ts
├── src
├── static
├── tsconfig.json
├── tslint.json
├── utils
├── vendor-manifest.json
└── yarn.lock


This is my webpackConfig File:



'use strict';
const path = require('path');
const os = require('os');
const webpack = require('webpack');
const HtmlWebpacPlugin = require('html-webpack-plugin');
const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

const CopyWebpackPlugin = require('copy-webpack-plugin');

const devMode = process.env.NODE_ENV !== 'production';

module.exports =
context: path.resolve(__dirname, '../cms2'),
entry: './src/index.tsx',
output:
path: path.resolve(__dirname, '../../../../dist/interface/www/cms2'),
publicPath: '/cms2/',
filename: 'scripts/[name].[contenthash].js',
chunkFilename: 'scripts/[id].[chunkhash].js',
,
module:
rules: [

test: /.tsx?$/,
use: [
loader: 'cache-loader' ,

loader: 'thread-loader',
options:
// there should be 1 cpu for the fork-ts-checker-webpack-plugin
workers: os.cpus().length - 1,
,
,

loader: 'ts-loader',
options:
happyPackMode: true, // IMPORTANT! use happyPackMode mode to speed-up compilation and reduce errors reported to webpack
,
,
],
,

test: /.scss$/,
use: [
MiniCssExtractPlugin.loader,

loader: 'css-loader',
options:
modules: true,
importLoader: 2,
minimize: true,
,
,
'sass-loader',
],
,
gif)$/,
use: [

loader: 'file-loader',
options:
name: devMode ? 'images/[name].[ext]' : 'images/[hash].[ext]',
,
,
],
,
],
,
// 解析
resolve:
modules: [path.resolve(__dirname, '../cms2/node_modules')],
extensions: ['.ts', '.tsx', '.js', '.jsx'],
,
plugins: [
new CleanWebpackPlugin(['cms2'],
root: '/project/dist/interface/www/',
verbose: true,
),
new CopyWebpackPlugin([

from: path.resolve(__dirname, '../static'),
to: path.resolve(__dirname, '../../../../dist/interface/www/cms2'),
,
]),
new HtmlWebpacPlugin(
template: path.resolve(__dirname, '../index.html'),
title: 'xxx',
favicon: '../favicon.ico',
),
new MiniCssExtractPlugin(
filename: devMode ? 'css/[name].css' : 'css/[name].[hash].css',
chunkFilename: devMode ? 'css/[id].css' : 'css/[id].[hash].css',
),
new webpack.DllReferencePlugin(
context: __dirname,
manifest: require('../vendor-manifest.json'),
),
new HtmlWebpackIncludeAssetsPlugin(
files: ['index.html'],
assets: ['vendor.dll.js'],
append: false,
),
],
;


This is my express File:



app.use(
webpackDevMiddleware(compiler,
publicPath: webPackDevConfig.output.publicPath,
)
);









share|improve this question









New contributor




XuZiHao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    1
    down vote

    favorite












    this is error message 1



    enter image description here



    I don't know why, my package goes to the folder where the current file is located instead of going to node_modules.



    this is error message 2



    enter image description here



    This is my root Folder tree:



    .
    ├── dist
    ├── gulpfile.js
    ├── interface
    ├── node_modules
    ├── package.json
    ├── README.md
    ├── scripts
    ├── spec
    ├── __test__
    ├── yarn.lock
    └── yarn-offline


    This is my cms2 Folder tree:



    .
    ├── bin
    ├── config
    ├── createStore.ts
    ├── css
    ├── declarations.d.ts
    ├── env.ts
    ├── favicon.ico
    ├── index.html
    ├── node_modules
    ├── package.json
    ├── redux-form-immutable.d.ts
    ├── src
    ├── static
    ├── tsconfig.json
    ├── tslint.json
    ├── utils
    ├── vendor-manifest.json
    └── yarn.lock


    This is my webpackConfig File:



    'use strict';
    const path = require('path');
    const os = require('os');
    const webpack = require('webpack');
    const HtmlWebpacPlugin = require('html-webpack-plugin');
    const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');
    const CleanWebpackPlugin = require('clean-webpack-plugin');
    const MiniCssExtractPlugin = require('mini-css-extract-plugin');

    const CopyWebpackPlugin = require('copy-webpack-plugin');

    const devMode = process.env.NODE_ENV !== 'production';

    module.exports =
    context: path.resolve(__dirname, '../cms2'),
    entry: './src/index.tsx',
    output:
    path: path.resolve(__dirname, '../../../../dist/interface/www/cms2'),
    publicPath: '/cms2/',
    filename: 'scripts/[name].[contenthash].js',
    chunkFilename: 'scripts/[id].[chunkhash].js',
    ,
    module:
    rules: [

    test: /.tsx?$/,
    use: [
    loader: 'cache-loader' ,

    loader: 'thread-loader',
    options:
    // there should be 1 cpu for the fork-ts-checker-webpack-plugin
    workers: os.cpus().length - 1,
    ,
    ,

    loader: 'ts-loader',
    options:
    happyPackMode: true, // IMPORTANT! use happyPackMode mode to speed-up compilation and reduce errors reported to webpack
    ,
    ,
    ],
    ,

    test: /.scss$/,
    use: [
    MiniCssExtractPlugin.loader,

    loader: 'css-loader',
    options:
    modules: true,
    importLoader: 2,
    minimize: true,
    ,
    ,
    'sass-loader',
    ],
    ,
    gif)$/,
    use: [

    loader: 'file-loader',
    options:
    name: devMode ? 'images/[name].[ext]' : 'images/[hash].[ext]',
    ,
    ,
    ],
    ,
    ],
    ,
    // 解析
    resolve:
    modules: [path.resolve(__dirname, '../cms2/node_modules')],
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
    ,
    plugins: [
    new CleanWebpackPlugin(['cms2'],
    root: '/project/dist/interface/www/',
    verbose: true,
    ),
    new CopyWebpackPlugin([

    from: path.resolve(__dirname, '../static'),
    to: path.resolve(__dirname, '../../../../dist/interface/www/cms2'),
    ,
    ]),
    new HtmlWebpacPlugin(
    template: path.resolve(__dirname, '../index.html'),
    title: 'xxx',
    favicon: '../favicon.ico',
    ),
    new MiniCssExtractPlugin(
    filename: devMode ? 'css/[name].css' : 'css/[name].[hash].css',
    chunkFilename: devMode ? 'css/[id].css' : 'css/[id].[hash].css',
    ),
    new webpack.DllReferencePlugin(
    context: __dirname,
    manifest: require('../vendor-manifest.json'),
    ),
    new HtmlWebpackIncludeAssetsPlugin(
    files: ['index.html'],
    assets: ['vendor.dll.js'],
    append: false,
    ),
    ],
    ;


    This is my express File:



    app.use(
    webpackDevMiddleware(compiler,
    publicPath: webPackDevConfig.output.publicPath,
    )
    );









    share|improve this question









    New contributor




    XuZiHao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      this is error message 1



      enter image description here



      I don't know why, my package goes to the folder where the current file is located instead of going to node_modules.



      this is error message 2



      enter image description here



      This is my root Folder tree:



      .
      ├── dist
      ├── gulpfile.js
      ├── interface
      ├── node_modules
      ├── package.json
      ├── README.md
      ├── scripts
      ├── spec
      ├── __test__
      ├── yarn.lock
      └── yarn-offline


      This is my cms2 Folder tree:



      .
      ├── bin
      ├── config
      ├── createStore.ts
      ├── css
      ├── declarations.d.ts
      ├── env.ts
      ├── favicon.ico
      ├── index.html
      ├── node_modules
      ├── package.json
      ├── redux-form-immutable.d.ts
      ├── src
      ├── static
      ├── tsconfig.json
      ├── tslint.json
      ├── utils
      ├── vendor-manifest.json
      └── yarn.lock


      This is my webpackConfig File:



      'use strict';
      const path = require('path');
      const os = require('os');
      const webpack = require('webpack');
      const HtmlWebpacPlugin = require('html-webpack-plugin');
      const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');
      const CleanWebpackPlugin = require('clean-webpack-plugin');
      const MiniCssExtractPlugin = require('mini-css-extract-plugin');

      const CopyWebpackPlugin = require('copy-webpack-plugin');

      const devMode = process.env.NODE_ENV !== 'production';

      module.exports =
      context: path.resolve(__dirname, '../cms2'),
      entry: './src/index.tsx',
      output:
      path: path.resolve(__dirname, '../../../../dist/interface/www/cms2'),
      publicPath: '/cms2/',
      filename: 'scripts/[name].[contenthash].js',
      chunkFilename: 'scripts/[id].[chunkhash].js',
      ,
      module:
      rules: [

      test: /.tsx?$/,
      use: [
      loader: 'cache-loader' ,

      loader: 'thread-loader',
      options:
      // there should be 1 cpu for the fork-ts-checker-webpack-plugin
      workers: os.cpus().length - 1,
      ,
      ,

      loader: 'ts-loader',
      options:
      happyPackMode: true, // IMPORTANT! use happyPackMode mode to speed-up compilation and reduce errors reported to webpack
      ,
      ,
      ],
      ,

      test: /.scss$/,
      use: [
      MiniCssExtractPlugin.loader,

      loader: 'css-loader',
      options:
      modules: true,
      importLoader: 2,
      minimize: true,
      ,
      ,
      'sass-loader',
      ],
      ,
      gif)$/,
      use: [

      loader: 'file-loader',
      options:
      name: devMode ? 'images/[name].[ext]' : 'images/[hash].[ext]',
      ,
      ,
      ],
      ,
      ],
      ,
      // 解析
      resolve:
      modules: [path.resolve(__dirname, '../cms2/node_modules')],
      extensions: ['.ts', '.tsx', '.js', '.jsx'],
      ,
      plugins: [
      new CleanWebpackPlugin(['cms2'],
      root: '/project/dist/interface/www/',
      verbose: true,
      ),
      new CopyWebpackPlugin([

      from: path.resolve(__dirname, '../static'),
      to: path.resolve(__dirname, '../../../../dist/interface/www/cms2'),
      ,
      ]),
      new HtmlWebpacPlugin(
      template: path.resolve(__dirname, '../index.html'),
      title: 'xxx',
      favicon: '../favicon.ico',
      ),
      new MiniCssExtractPlugin(
      filename: devMode ? 'css/[name].css' : 'css/[name].[hash].css',
      chunkFilename: devMode ? 'css/[id].css' : 'css/[id].[hash].css',
      ),
      new webpack.DllReferencePlugin(
      context: __dirname,
      manifest: require('../vendor-manifest.json'),
      ),
      new HtmlWebpackIncludeAssetsPlugin(
      files: ['index.html'],
      assets: ['vendor.dll.js'],
      append: false,
      ),
      ],
      ;


      This is my express File:



      app.use(
      webpackDevMiddleware(compiler,
      publicPath: webPackDevConfig.output.publicPath,
      )
      );









      share|improve this question









      New contributor




      XuZiHao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      this is error message 1



      enter image description here



      I don't know why, my package goes to the folder where the current file is located instead of going to node_modules.



      this is error message 2



      enter image description here



      This is my root Folder tree:



      .
      ├── dist
      ├── gulpfile.js
      ├── interface
      ├── node_modules
      ├── package.json
      ├── README.md
      ├── scripts
      ├── spec
      ├── __test__
      ├── yarn.lock
      └── yarn-offline


      This is my cms2 Folder tree:



      .
      ├── bin
      ├── config
      ├── createStore.ts
      ├── css
      ├── declarations.d.ts
      ├── env.ts
      ├── favicon.ico
      ├── index.html
      ├── node_modules
      ├── package.json
      ├── redux-form-immutable.d.ts
      ├── src
      ├── static
      ├── tsconfig.json
      ├── tslint.json
      ├── utils
      ├── vendor-manifest.json
      └── yarn.lock


      This is my webpackConfig File:



      'use strict';
      const path = require('path');
      const os = require('os');
      const webpack = require('webpack');
      const HtmlWebpacPlugin = require('html-webpack-plugin');
      const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');
      const CleanWebpackPlugin = require('clean-webpack-plugin');
      const MiniCssExtractPlugin = require('mini-css-extract-plugin');

      const CopyWebpackPlugin = require('copy-webpack-plugin');

      const devMode = process.env.NODE_ENV !== 'production';

      module.exports =
      context: path.resolve(__dirname, '../cms2'),
      entry: './src/index.tsx',
      output:
      path: path.resolve(__dirname, '../../../../dist/interface/www/cms2'),
      publicPath: '/cms2/',
      filename: 'scripts/[name].[contenthash].js',
      chunkFilename: 'scripts/[id].[chunkhash].js',
      ,
      module:
      rules: [

      test: /.tsx?$/,
      use: [
      loader: 'cache-loader' ,

      loader: 'thread-loader',
      options:
      // there should be 1 cpu for the fork-ts-checker-webpack-plugin
      workers: os.cpus().length - 1,
      ,
      ,

      loader: 'ts-loader',
      options:
      happyPackMode: true, // IMPORTANT! use happyPackMode mode to speed-up compilation and reduce errors reported to webpack
      ,
      ,
      ],
      ,

      test: /.scss$/,
      use: [
      MiniCssExtractPlugin.loader,

      loader: 'css-loader',
      options:
      modules: true,
      importLoader: 2,
      minimize: true,
      ,
      ,
      'sass-loader',
      ],
      ,
      gif)$/,
      use: [

      loader: 'file-loader',
      options:
      name: devMode ? 'images/[name].[ext]' : 'images/[hash].[ext]',
      ,
      ,
      ],
      ,
      ],
      ,
      // 解析
      resolve:
      modules: [path.resolve(__dirname, '../cms2/node_modules')],
      extensions: ['.ts', '.tsx', '.js', '.jsx'],
      ,
      plugins: [
      new CleanWebpackPlugin(['cms2'],
      root: '/project/dist/interface/www/',
      verbose: true,
      ),
      new CopyWebpackPlugin([

      from: path.resolve(__dirname, '../static'),
      to: path.resolve(__dirname, '../../../../dist/interface/www/cms2'),
      ,
      ]),
      new HtmlWebpacPlugin(
      template: path.resolve(__dirname, '../index.html'),
      title: 'xxx',
      favicon: '../favicon.ico',
      ),
      new MiniCssExtractPlugin(
      filename: devMode ? 'css/[name].css' : 'css/[name].[hash].css',
      chunkFilename: devMode ? 'css/[id].css' : 'css/[id].[hash].css',
      ),
      new webpack.DllReferencePlugin(
      context: __dirname,
      manifest: require('../vendor-manifest.json'),
      ),
      new HtmlWebpackIncludeAssetsPlugin(
      files: ['index.html'],
      assets: ['vendor.dll.js'],
      append: false,
      ),
      ],
      ;


      This is my express File:



      app.use(
      webpackDevMiddleware(compiler,
      publicPath: webPackDevConfig.output.publicPath,
      )
      );






      webpack webpack-dev-middleware






      share|improve this question









      New contributor




      XuZiHao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      XuZiHao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 2 days ago









      Armali

      6,76793595




      6,76793595






      New contributor




      XuZiHao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      XuZiHao

      61




      61




      New contributor




      XuZiHao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      XuZiHao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      XuZiHao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          XuZiHao is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225194%2fwebpack-dev-middleware-my-ts-module-parsing-error-after-use%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          XuZiHao is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          XuZiHao is a new contributor. Be nice, and check out our Code of Conduct.












          XuZiHao is a new contributor. Be nice, and check out our Code of Conduct.











          XuZiHao is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225194%2fwebpack-dev-middleware-my-ts-module-parsing-error-after-use%23new-answer', 'question_page');

          );

          Post as a guest














































































          Popular posts from this blog

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Syphilis

          Darth Vader #20