加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

node.js – Webpack不生成build.js

发布时间:2020-12-16 03:42:44 所属栏目:安全 来源:网络整理
导读:我将代码库移到了dockerformat. 我有一个docker-compose文件,其中包含以下命令: 命令:bash -c“rm -rf node_modules npm install npm run dev” 一切正常,我使用rm -rf node_modules因为它给了我一些丢失包的错误(来自我的MAC).这样做只是重新创建它在loca

我将代码库移到了dockerformat.

我有一个docker-compose文件,其中包含以下命令:
命令:bash -c“rm -rf node_modules&& npm install&& npm run dev”

一切正常,我使用rm -rf node_modules因为它给了我一些丢失包的错误(来自我的MAC).这样做只是重新创建它在localhost上正常工作.

我还添加了卷,所以当我在我的代码中更改某些东西时会反映在我的容器中,这也可以正常工作(除了热重载,但这不是什么大问题).

现在我通常只注释掉这行:命令:bash -c“rm -rf node_modules&& npm install&& npm run dev”在我的docker-compose文件中,而是我添加:
命令:bash -c“rm -rf node_modules&& npm install&& npm run build”来构建我的bundle,所以在生产中我根本没有节点,但是这没有给我带来任何结果.

我不确定它是否是卷的问题,即它是在容器中构建但我无法从我的机器访问它(我不认为因为我本地机器中的代码更改会反映在我的容器中)或者由于某种原因它根本没有建成.

这是命令的输出:bash -c“rm -rf node_modules&& npm install&& npm run build –verbose”

NODE     | npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
NODE     | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
NODE     | 
NODE     | added 115 packages in 11.036s
NODE     | npm info it worked if it ends with ok
NODE     | npm verb cli [ '/usr/local/bin/node',NODE     | npm verb cli   '/usr/local/bin/npm',NODE     | npm verb cli   'run',NODE     | npm verb cli   'build',NODE     | npm verb cli   '--verbose' ]
NODE     | npm info using npm@5.5.1
NODE     | npm info using node@v9.2.0
NODE     | npm verb run-script [ 'prebuild','build','postbuild' ]
NODE     | npm info lifecycle frontend@1.0.0~prebuild: frontend@1.0.0
NODE     | npm info lifecycle frontend@1.0.0~build: frontend@1.0.0
NODE     | 
NODE     | > frontend@1.0.0 build /code/client
NODE     | > cross-env NODE_ENV=production webpack --progress --hide-modules
NODE     | 
NODE     | Hash: cda5e46c2c7f4ba2903b                                                              
NODE     | Version: webpack 3.9.1
NODE     | Time: 27298ms
NODE     |        Asset     Size  Chunks                    Chunk Names
NODE     |     build.js  1.29 MB       0  [emitted]  [big]  main
NODE     | build.js.map  7.65 MB       0  [emitted]         main
NODE     | npm verb lifecycle frontend@1.0.0~build: unsafe-perm in lifecycle true
NODE     | npm verb lifecycle frontend@1.0.0~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/code/client/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NODE     | npm verb lifecycle frontend@1.0.0~build: CWD: /code/client
NODE     | npm info lifecycle frontend@1.0.0~postbuild: frontend@1.0.0
NODE     | npm verb exit [ 0,true ]
NODE     | npm info ok

我的webpack conf文件就像这样开始:

var path = require('path')
var webpack = require('webpack') 

module.exports = {
  entry: './src/main.js',output: {
    path: path.resolve(__dirname,'../static/dist/'),publicPath: '/dist/',filename: 'build.js'
  },

至少之前工作正常,因为我的应用程序看起来像这样:

- manage.py
- static
  - dist
  - others
- client
  - webpack.config.js

等等

为什么没有什么东西可以建立?

更新

我使用exec查看容器内部.我无法在任何地方找到build.js.我也在/ code / static / dist中运行touch abc.txt,它也在我的localhost上创建,即卷工作正常.它必须是webpack的问题而不是docker.

更新2

我也试过这样的完整路径,但仍然没有:

module.exports = {
  entry: './src/main.js','/code/static/dist'),

编辑3

我试图寻找build.js我找到了这些文件,但我认为那些不是我的build.js:

root@0xxxxxx:/code# find . -name build.js
./client/node_modules/node-forge/nodejs/build.js
./client/node_modules/errno/build.js
./client/node_modules/vue-template-compiler/build.js
./client/node_modules/builtin-status-codes/build.js
./client/node_modules/webpack-dev-middleware/node_modules/mime/src/build.js
./client/node_modules/node-gyp/lib/build.js
./client/node_modules/node-sass/scripts/build.js
./client/node_modules/mime/build/build.js
./client/node_modules/npm/node_modules/node-gyp/lib/build.js
./client/node_modules/npm/node_modules/sorted-union-stream/node_modules/from2/node_modules/readable-stream/node_modules/isarray/build/build.js
./client/node_modules/npm/lib/install/action/build.js
./client/node_modules/npm/lib/build.js
最佳答案
你的道路是错的.您从项目目录中构建build.js文件.

只需改为:

path:path.resolve(__ dirname,’static / dist’)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读