我在將rxjs
加載到簡單的webpack安裝程序(無角)時遇到問題。我正在運行:無法解析在typescript/webpack中找不到'rxjs'模塊
./node_modules/.bin/webpack --config webpack.config.js --watch
啓動webpack。與應用程序,src/app.ts
,唯一的文件的開頭爲:
import { Observable } from 'rxjs';
和這條線在VSCode和的WebPack控制檯與此錯誤強調:
Cannot find module 'rxjs'.
但整體輸出工作正常。只是這個控制檯錯誤。
tsconfig.json
:
{
"compilerOptions": {
"target": "es2015"
},
"files": [
"src/app.ts"
]
}
webpack.config.js
:
module.exports = {
entry: "./src/app.ts",
output: {
filename: "dist/bundle.js"
},
resolve: {
// Add '.ts' and '.tsx' as a resolvable extension.
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"]
},
module: {
loaders: [
// all files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'
{ test: /\.ts?$/, loader: "ts-loader" }
]
}
}
package.json
(正確安裝的所有內容):
{
"scripts": {
"start": "./node_modules/.bin/webpack --config webpack.config.js --watch"
},
"devDependencies": {
"ts-loader": "^2.1.0",
"typescript": "^2.3.4",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"bootstrap": "^3.3.7",
"rxjs": "^5.4.0"
}
}
我找不到理由爲什麼不能TS/webpack解析在哪裏是rxjs
這並沒有太大的意義給我; [docs](https://webpack.js.org/configuration/resolve/#resolve-modules)表示'resolve.modules'默認爲''node_modules「',所以我不需要添加它,I只是不要改變它。我不需要在那裏添加''app'',爲什麼? – ducin