chang-ke / Compiler-Principle

词法分析,LL(1) 文法分析,LR(1) 文法分析

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

构建错误

newcoderlife opened this issue · comments

commented

您好,我尝试运行您的代码,npm install成功无错误,但npm start server输出如下:

> compiler@0.1.0 start /home/newcoderlife/Compiler-Principle
> node index.js "server"

internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module 'koa'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/home/newcoderlife/Compiler-Principle/http/app.js:1:75)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module 'koa'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/home/newcoderlife/Compiler-Principle/http/app.js:1:75)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
{ Error: Command failed: cd view && npm start
sh: 1: webpack-dev-server: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! compiler@0.1.0 start: `webpack-dev-server --hot --inline --color --hot --config ./scripts/webpack.dev.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the compiler@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/newcoderlife/.npm/_logs/2018-12-20T07_11_02_831Z-debug.log

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:978:16)
    at Socket.stream.socket.on (internal/child_process.js:395:11)
    at Socket.emit (events.js:189:13)
    at Pipe._handle.close (net.js:610:12)
  killed: false,
  code: 1,
  signal: null,
  cmd: 'cd view && npm start' }
{ Error: Command failed: cd view && npm start
sh: 1: webpack-dev-server: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! compiler@0.1.0 start: `webpack-dev-server --hot --inline --color --hot --config ./scripts/webpack.dev.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the compiler@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/newcoderlife/.npm/_logs/2018-12-20T07_11_04_096Z-debug.log

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:978:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
  killed: false,
  code: 1,
  signal: null,
  cmd: 'cd view && npm start' }

根据错误信息,我运行了sudo npm install koa -g,仍旧报错。

希望能够得到您的帮助,谢谢!

commented

请问您是在 Windows 10 环境下运行,还是在 WSL 环境下呢?

commented

通过安装一系列的koa相关包,现在npm run server不报错,但是npm run dev报错,错误信息如下:

> compiler@0.1.0 dev /home/newcoderlife/Compiler-Principle
> cd view && npm start


> compiler@0.1.0 start /home/newcoderlife/Compiler-Principle/view
> webpack-dev-server --hot --inline --color --hot --config ./scripts/webpack.dev.js

The CLI moved into a separate package: webpack-cli
Please install 'webpack-cli' in addition to webpack itself to use the CLI
-> When using npm: npm i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/usr/lib/node_modules/webpack-dev-server/bin/webpack-dev-server.js:84:1)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! compiler@0.1.0 start: `webpack-dev-server --hot --inline --color --hot --config ./scripts/webpack.dev.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the compiler@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/newcoderlife/.npm/_logs/2018-12-20T07_44_27_380Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! compiler@0.1.0 dev: `cd view && npm start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the compiler@0.1.0 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!     /home/newcoderlife/.npm/_logs/2018-12-20T07_44_27_535Z-debug.log

请问我是否仍然缺少一些依赖包?谢谢!

非常抱歉,从错误提示来看,你需要安装 webpack-cli

commented

已经解决了,感谢大佬的帮助。