错误:产生/ data / craft / templates / node_modules / optipng-bin / vendor / optipng ENOENT

时间:2019-03-25 08:52:44

标签: node.js linux npm alpine

我尝试在Alpine Linux容器中运行$ npm run prod并收到错误消息。

我遵循了程序

  1. 在linux的/data目录中,我运行命令$ apk add --update nodejs nodejs-npm,该命令将nodenpm安装在容器中
  2. 我进入/data/craft/templets目录并运行命令$ npm install
  3. 在同一位置,我运行命令$ npm run prod

我得到了错误堆栈

bash-4.3# npm run prod 

> welance-craft-base-template@0.2.0 prod /data/craft/templates
> NODE_ENV='prod' env UV_THREADPOOL_SIZE=100 webpack -p --config webpack/webpack.prod.js

clean-webpack-plugin: /data/craft/public/assets is outside of the project root. Skipping...
Error: spawn /data/craft/templates/node_modules/optipng-bin/vendor/optipng ENOENT
    at exports._errnoException (util.js:1018:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

npm ERR! Linux 4.9.87-linuxkit-aufs
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "prod"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! welance-craft-base-template@0.2.0 prod: `NODE_ENV='prod' env UV_THREADPOOL_SIZE=100 webpack -p --config webpack/webpack.prod.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the welance-craft-base-template@0.2.0 prod script 'NODE_ENV='prod' env UV_THREADPOOL_SIZE=100 webpack -p --config webpack/webpack.prod.js'.
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 welance-craft-base-template package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV='prod' env UV_THREADPOOL_SIZE=100 webpack -p --config webpack/webpack.prod.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs welance-craft-base-template
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls welance-craft-base-template
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /data/craft/templates/npm-debug.log

我的文件夹

ietms are provided, 

bash-4.3# pwd
/data/craft/templates
bash-4.3# ls 
404.html                  _entries                  ea6dc030-add9-4616-97bb-8370c05e82cb  npm-shrinkwrap.json
4d5217b7-6edb-4d71-9149-a50085dbaa0e  _includes                 eb5f1516-3384-4171-9cec-4c71c9bb36e7  package.json
9a45fea3-db13-47a8-9fc0-6c7063f8d768  b7ee1be3-9d27-4602-a93e-0da6a2a5eaa9  efdf951a-587f-46ed-b2da-69ec16f10824  postcss.config.js
README.md                 ce149251-fed6-4083-bf27-d60fd41d7905  node_modules              web.config
__src                     e4701b6f-c517-4625-babd-578e6689805b  npm-debug.log             webpack

提供了Log输出,

bash-4.3# cat /data/craft/templates/npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'prod' ]
2 info using npm@3.10.10
3 info using node@v6.10.3
4 verbose run-script [ 'preprod', 'prod', 'postprod' ]
5 info lifecycle welance-craft-base-template@0.2.0~preprod: welance-craft-base-template@0.2.0
6 silly lifecycle welance-craft-base-template@0.2.0~preprod: no script for preprod, continuing
7 info lifecycle welance-craft-base-template@0.2.0~prod: welance-craft-base-template@0.2.0
8 verbose lifecycle welance-craft-base-template@0.2.0~prod: unsafe-perm in lifecycle true
9 verbose lifecycle welance-craft-base-template@0.2.0~prod: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/data/craft/templates/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
10 verbose lifecycle welance-craft-base-template@0.2.0~prod: CWD: /data/craft/templates
11 silly lifecycle welance-craft-base-template@0.2.0~prod: Args: [ '-c',
11 silly lifecycle   'NODE_ENV=\'prod\' env UV_THREADPOOL_SIZE=100 webpack -p --config webpack/webpack.prod.js' ]
12 silly lifecycle welance-craft-base-template@0.2.0~prod: Returned: code: 1  signal: null
13 info lifecycle welance-craft-base-template@0.2.0~prod: Failed to exec prod script
14 verbose stack Error: welance-craft-base-template@0.2.0 prod: `NODE_ENV='prod' env UV_THREADPOOL_SIZE=100 webpack -p --config webpack/webpack.prod.js`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:255: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/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:886:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid welance-craft-base-template@0.2.0
16 verbose cwd /data/craft/templates
17 error Linux 4.9.87-linuxkit-aufs
18 error argv "/usr/bin/node" "/usr/bin/npm" "run" "prod"
19 error node v6.10.3
20 error npm  v3.10.10
21 error code ELIFECYCLE
22 error welance-craft-base-template@0.2.0 prod: `NODE_ENV='prod' env UV_THREADPOOL_SIZE=100 webpack -p --config webpack/webpack.prod.js`
22 error Exit status 1
23 error Failed at the welance-craft-base-template@0.2.0 prod script 'NODE_ENV='prod' env UV_THREADPOOL_SIZE=100 webpack -p --config webpack/webpack.prod.js'.
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 welance-craft-base-template package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     NODE_ENV='prod' env UV_THREADPOOL_SIZE=100 webpack -p --config webpack/webpack.prod.js
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs welance-craft-base-template
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls welance-craft-base-template
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

下面提供了文件webpack/webpack.prod.js

bash-4.3# cat webpack/webpack.prod.js
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');

const webpack = require("webpack");
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const ImageminWebpackPlugin = require('imagemin-webpack-plugin').default;
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');

const imagesPath = path.resolve(__dirname, '../__src/images');
const rootPath = path.resolve(__dirname);

module.exports = merge(common, {
  devtool: 'source-map',
  plugins: [
        //about SASS compilation
        new ExtractTextPlugin({
            filename: "styles/main.min.css"
        }),
        new ImageminWebpackPlugin({
            test: /\.(jpe?g|png|gif|svg)$/i,
            //disable: process.env.NODE_ENV !== 'prod',
            pngquant: {
                quality: '95-100'
            },
            optipng: {
                optimizationLevel: 5 //0-7 (7 slower)
            },
            jpegtran: {
                progressive: true
            },
            gifsicle: {
                optimizationLevel: 3 //1-3 (3 slower)
            }
        }),
        new FaviconsWebpackPlugin({
            // Your source logo
            logo: imagesPath + '/favicon.png',
            // The prefix for all image files (might be a folder or a name)
            prefix: 'images/icons-[hash]/',
            // Emit all stats of the generated icons
            emitStats: false,
            // The name of the json containing all favicon information
            statsFilename: 'iconstats-[hash].json',
            // Generate a cache file with control hashes and
            // don't rebuild the favicons until those hashes change
            persistentCache: true,
            // Inject the html into the html-webpack-plugin
            inject: true,
            // favicon background color (see https://github.com/haydenbleasel/favicons#usage)
            //background: '#fff',
            // favicon app title (see https://github.com/haydenbleasel/favicons#usage)
            title: 'GGFutures.net',

            // which icons should be generated (see https://github.com/haydenbleasel/favicons#usage)
            icons: {
                android: true,
                appleIcon: true,
                appleStartup: true,
                coast: false,
                favicons: true,
                firefox: true,
                opengraph: false,
                twitter: false,
                yandex: false,
                windows: false
            }
        }),
    new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'scripts/vendor.min.js?h=[hash]' })
  ]
})

谢谢。

PS 我尝试删除节点模块,然后再次重新安装npm,但效果不佳,

$ rm -rf node_modules/
$ npm install

我也尝试过使用这些命令,

$ npm install rimraf -g
$ rimraf node_modules

1 个答案:

答案 0 :(得分:1)

所以我遇到了同样的问题,尤其是在ec2实例上运行这些命令。

运行npm rebuild,它应该处理与此有关的所有问题。