前提条件:安装nodejs。需要用到npm和cnpm
可在终端中查看node版本:
C:\Users\璐从今夜白。>node -v
v12.18.3
安装步骤如下:
第一步:命令行安装REMIX IDE
CTRL+R调出WINDOWS命令行窗口,输入以下命令安装remix-ide本地环境。
npm install remix-ide -g
安装成功结果输出如下:
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
C:\Users\璐从今夜白。\AppData\Roaming\npm\remix-ide -> C:\Users\璐从今夜白。\AppData\Roaming\npm\node_modules\remix-ide\bin\remix-ide
+ remix-ide@0.10.3
added 177 packages from 188 contributors in 42.411s
第二步:启动本地IDE
在WINDOWS CMD中输入REMIX-IDE启动程序:
D:\remix>remix-ide
正常返回应该是:
Starting Remix IDE at http://localhost:8080 and sharing D:\remix
但我在执行报错遇到问题如下:
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module 'remixd'
Require stack:
- C:\Users\璐从今夜白。\AppData\Roaming\npm\node_modules\remix-ide\bin\remix-ide
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\璐从今夜白。\AppData\Roaming\npm\node_modules\remix-ide\bin\remix-ide:4:14)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\璐从今夜白。\\AppData\\Roaming\\npm\\node_modules\\remix-ide\\bin\\remix-ide'
]
}
解决方式: 在报错路径中 \AppData\Roaming\npm\node_modules\remix-ide\bin\remix-ide下,去删除remixd相关内容
去除之前,如下:
#!/usr/bin/env node
var path = require(‘path’)
var httpServer = require(‘http-server’)
var remixd = require(‘remixd’)
var server = httpServer.createServer({
root: path.join(__dirname, ‘/…/’)
})
var folder = process.argv.length > 2 ? process.argv[2] : process.cwd()
server.listen(8080, ‘127.0.0.1’, function () {})
var router = new remixd.Router(65520, remixd.services.sharedFolder, { remixIdeUrl: ‘http://localhost:8080’ }, (webSocket) => {
remixd.services.sharedFolder.setWebSocket(webSocket)
remixd.services.sharedFolder.setupNotifications(folder)
remixd.services.sharedFolder.sharedFolder(folder, false)
})
router.start()
console.log(’\x1b[33m%s\x1b[0m’, 'Starting Remix IDE at http://localhost:8080 and sharing ’ + folder)
去除之后如下:
#!/usr/bin/env node
var path = require(‘path’)
var httpServer = require(‘http-server’)
var server = httpServer.createServer({
root: path.join(__dirname, ‘/…/’)
})
var folder = process.argv.length > 2 ? process.argv[2] : process.cwd()
server.listen(8080, ‘127.0.0.1’, function () {})
console.log(’\x1b[33m%s\x1b[0m’, 'Starting Remix IDE at http://localhost:8080 and sharing ’ + folder)
启动成功后,输入 localhost:8080不行的话,可以考虑加个路径/index ,即:localhost:8080/index,就可以啦