编译反应js和nojs代码时出错

时间:2017-02-07 06:14:57

标签: node.js reactjs

我在react和node js中创建了一个新项目。使用“node --harmony bin / webpack-dev-server”进行编译时,我得到的项目误差低于此值。我怎么能解决这个问题。

 D:\workspace\myproject>node --harmony bin/webpack-dev-server
   { Error: ENOENT: no such file or directory, open           'D:\workspace\myproject\.env'
at Error (native)
at Object.fs.openSync (fs.js:640:51)
at Object.fs.readFileSync (fs.js:508:33)
at Object.config (D:\workspace\myproject\node_modules\dotenv\lib\main.js:30:37)
at Object.<anonymous> (D:/workspace/myproject/config/index.js:5:8)
at Module._compile (module.js:570:32)
at normalLoader (D:\workspace\myproject\node_modules\babel-  
core\lib\api\register\node.js:199:5)
 at Object.require.extensions.(anonymous function) [as .js] 
 (D:\workspace\myproject\node_modules\babel
 -core\lib\api\register\node.js:216:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
 errno: -4058,
code: 'ENOENT',
 syscall: 'open',
path: 'D:\\workspace\\myproject\\.env' }
module.js:471
throw err;
^

Error: Cannot find module './api-env/ci'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:/workspace/myproject/build/webpack/_base.js:23:30)
at Module._compile (module.js:570:32)
 at normalLoader (D:\workspace\myproject\node_modules\babel-
 core\lib\api\register\node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js]     
 (D:\workspace\myproject\node_modules\babel
  -core\lib\api\register\node.js:216:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
   (D:\workspace\myproject\build\webpack\development.js:9:13)
  at Module._compile (module.js:570:32)
  at normalLoader (D:\workspace\myproject\node_modules\babel-
 core\lib\api\register\node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] 
(D:\workspace\myproject\node_modules\babel
-core\lib\api\register\node.js:216:7)
at Module.load (module.js:487:32)

1 个答案:

答案 0 :(得分:0)

您的index.js看起来正在寻找.env文件。尝试在应用程序的根文件夹中创建名为.env的文件。